Example usage for android.widget TextView setVisibility

List of usage examples for android.widget TextView setVisibility

Introduction

In this page you can find the example usage for android.widget TextView setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.benefit.buy.library.viewpagerindicator.PagerSlidingTabStrip.java

private void addIconTab(final int position, String title, int iconResId, int iconResclickId, int count) {
    //        TextView tab = new TextView(getContext());
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View tabView = inflater.inflate(R.layout.item_tab, null);
    ImageView clickImg = (ImageView) tabView.findViewById(R.id.img_click);
    ImageView outImg = (ImageView) tabView.findViewById(R.id.img_out);
    TextView text = (TextView) tabView.findViewById(R.id.tab_name);
    TextView textHint = (TextView) tabView.findViewById(R.id.tab_hint_number);
    text.setText(title);/*from   ww  w . j a  va 2s  . co  m*/
    outImg.setImageResource(iconResId);
    clickImg.setImageResource(iconResclickId);
    //        tab.setGravity(Gravity.CENTER);
    //        tab.setSingleLine();
    //        if (iconResId != 0) {
    //            tab.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
    //            tab.setBackgroundResource(iconResId);
    //        }
    if (count <= 0) {
        textHint.setVisibility(View.GONE);
    } else {
        textHint.setVisibility(View.VISIBLE);
        textHint.setText(count + "");
    }
    addTab(position, tabView);
}

From source file:com.google.sample.castcompanionlibrary.cast.tracks.ui.TracksChooserDialog.java

private void setupView(View view) {
    ListView listView1 = (ListView) view.findViewById(R.id.listview1);
    ListView listView2 = (ListView) view.findViewById(R.id.listview2);
    TextView textEmptyMessageView = (TextView) view.findViewById(R.id.text_empty_message);
    TextView audioEmptyMessageView = (TextView) view.findViewById(R.id.audio_empty_message);
    partitionTracks();//  ww  w.j ava 2 s  .com

    mTextAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mTextTracks,
            mSelectedTextPosition);
    mAudioVideoAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mAudioTracks,
            mSelectedAudioPosition);

    listView1.setAdapter(mTextAdapter);
    listView2.setAdapter(mAudioVideoAdapter);

    TabHost tabs = (TabHost) view.findViewById(R.id.tabhost);
    tabs.setup();

    // create tab 1
    TabHost.TabSpec tab1 = tabs.newTabSpec("tab1");
    if (mTextTracks == null || mTextTracks.isEmpty()) {
        listView1.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.text_empty_message);
    } else {
        textEmptyMessageView.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.listview1);
    }
    tab1.setIndicator(getString(R.string.caption_subtitles));
    tabs.addTab(tab1);

    // create tab 2
    TabHost.TabSpec tab2 = tabs.newTabSpec("tab2");
    if (mAudioTracks == null || mAudioTracks.isEmpty()) {
        listView2.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.audio_empty_message);
    } else {
        audioEmptyMessageView.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.listview2);
    }
    tab2.setIndicator(getString(R.string.caption_audio));
    tabs.addTab(tab2);
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.tracks.ui.TracksChooserDialog.java

private void setUpView(View view) {
    ListView listView1 = (ListView) view.findViewById(R.id.listview1);
    ListView listView2 = (ListView) view.findViewById(R.id.listview2);
    TextView textEmptyMessageView = (TextView) view.findViewById(R.id.text_empty_message);
    TextView audioEmptyMessageView = (TextView) view.findViewById(R.id.audio_empty_message);
    partitionTracks();//from  w w  w  .  j  ava  2s.c  om

    mTextAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mTextTracks,
            mSelectedTextPosition);
    mAudioVideoAdapter = new TracksListAdapter(getActivity(), R.layout.tracks_row_layout, mAudioTracks,
            mSelectedAudioPosition);

    listView1.setAdapter(mTextAdapter);
    listView2.setAdapter(mAudioVideoAdapter);

    TabHost tabs = (TabHost) view.findViewById(R.id.tabhost);
    tabs.setup();

    // create tab 1
    TabHost.TabSpec tab1 = tabs.newTabSpec("tab1");
    if (mTextTracks == null || mTextTracks.isEmpty()) {
        listView1.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.text_empty_message);
    } else {
        textEmptyMessageView.setVisibility(View.INVISIBLE);
        tab1.setContent(R.id.listview1);
    }
    tab1.setIndicator(getString(R.string.ccl_caption_subtitles));
    tabs.addTab(tab1);

    // create tab 2
    TabHost.TabSpec tab2 = tabs.newTabSpec("tab2");
    if (mAudioTracks == null || mAudioTracks.isEmpty()) {
        listView2.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.audio_empty_message);
    } else {
        audioEmptyMessageView.setVisibility(View.INVISIBLE);
        tab2.setContent(R.id.listview2);
    }
    tab2.setIndicator(getString(R.string.ccl_caption_audio));
    tabs.addTab(tab2);
}

From source file:android.com.example.contactslist.ui.ContactDetailFragment.java

/**
 * Builds an address LinearLayout based on address information from the Contacts Provider.
 * Each address for the contact gets its own LinearLayout object; for example, if the contact
 * has three postal addresses, then 3 LinearLayouts are generated.
 *
 * @param addressType From//w  w w. j a  v  a  2s.  c  o m
 * {@link StructuredPostal#TYPE}
 * @param addressTypeLabel From
 * {@link StructuredPostal#LABEL}
 * @param address From
 * {@link StructuredPostal#FORMATTED_ADDRESS}
 * @return A LinearLayout to add to the contact details layout,
 *         populated with the provided address details.
 */
private LinearLayout buildAddressLayout(int addressType, String addressTypeLabel, final String address) {

    // Inflates the address layout
    final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.contact_detail_item, mDetailsLayout, false);

    // Gets handles to the view objects in the layout
    final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header);
    final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item);
    final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address);

    // If there's no addresses for the contact, shows the empty view and message, and hides the
    // header and button.
    if (addressTypeLabel == null && addressType == 0) {
        headerTextView.setVisibility(View.GONE);
        viewAddressButton.setVisibility(View.GONE);
        addressTextView.setText(R.string.no_address);
    } else {
        // Gets postal address label type
        CharSequence label = StructuredPostal.getTypeLabel(getResources(), addressType, addressTypeLabel);

        // Sets TextView objects in the layout
        headerTextView.setText(label);
        addressTextView.setText(address);

        // Defines an onClickListener object for the address button
        viewAddressButton.setOnClickListener(new View.OnClickListener() {
            // Defines what to do when users click the address button
            @Override
            public void onClick(View view) {

                final Intent viewIntent = new Intent(Intent.ACTION_VIEW, constructGeoUri(address));

                // A PackageManager instance is needed to verify that there's a default app
                // that handles ACTION_VIEW and a geo Uri.
                final PackageManager packageManager = getActivity().getPackageManager();

                // Checks for an activity that can handle this intent. Preferred in this
                // case over Intent.createChooser() as it will still let the user choose
                // a default (or use a previously set default) for geo Uris.
                if (packageManager.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
                    startActivity(viewIntent);
                } else {
                    // If no default is found, displays a message that no activity can handle
                    // the view button.
                    Toast.makeText(getActivity(), R.string.no_intent_found, Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
    return addressLayout;
}

From source file:com.cw.litenote.note.NoteUi.java

public NoteUi(AppCompatActivity activity, ViewPager viewPager, int position) {

    System.out.println("NoteUi / constructor");
    pager = viewPager;// w  ww.j  a v a 2s.  c om
    act = activity;
    mPosition = position;

    DB_page db_page = new DB_page(act, TabsHost.getCurrentPageTableId());
    setNotesCnt(db_page.getNotesCount(true));
    String pictureUri = db_page.getNotePictureUri(position, true);
    String linkUri = db_page.getNoteLinkUri(position, true);

    String tagStr = "current" + position + "pictureView";
    ViewGroup pictureGroup = (ViewGroup) pager.findViewWithTag(tagStr);

    if ((pictureGroup != null)) {
        setPictureView_listeners(act, pager, pictureUri, linkUri, pictureGroup);

        TextView picView_footer = (TextView) (pictureGroup.findViewById(R.id.image_footer));

        Button picView_back_button = (Button) (pictureGroup.findViewById(R.id.image_view_back));
        Button picView_viewMode_button = (Button) (pictureGroup.findViewById(R.id.image_view_mode));

        TextView videoView_currPosition = (TextView) (pictureGroup.findViewById(R.id.video_current_pos));
        SeekBar videoView_seekBar = (SeekBar) (pictureGroup.findViewById(R.id.video_seek_bar));
        TextView videoView_fileLength = (TextView) (pictureGroup.findViewById(R.id.video_file_length));

        // show back button
        if (Note.isPictureMode())
            picView_back_button.setVisibility(View.VISIBLE);
        else
            picView_back_button.setVisibility(View.GONE);

        // Show picture title
        TextView picView_title;
        picView_title = (TextView) (pictureGroup.findViewById(R.id.image_title));
        String pictureName;
        if (!Util.isEmptyString(pictureUri))
            pictureName = Util.getDisplayNameByUriString(pictureUri, act);
        else if (Util.isYouTubeLink(linkUri))
            pictureName = linkUri;
        else
            pictureName = "";

        if (!Util.isEmptyString(pictureName)) {
            picView_title.setVisibility(View.VISIBLE);
            picView_title.setText(pictureName);
        } else
            picView_title.setVisibility(View.INVISIBLE);

        // show footer
        if (Note.isPictureMode()) {
            picView_footer.setVisibility(View.VISIBLE);
            picView_footer.setText((pager.getCurrentItem() + 1) + "/" + pager.getAdapter().getCount());
        } else
            picView_footer.setVisibility(View.GONE);

        // for video
        if (UtilVideo.hasVideoExtension(pictureUri, act)) {
            if (!UtilVideo.hasMediaControlWidget)
                NoteUi.updateVideoPlayButtonState(pager, getFocus_notePos());
            else
                show_picViewUI_previous_next(false, 0);
        }

        // set image view buttons (View Mode, Previous, Next) visibility
        if (Note.isPictureMode()) {
            picView_viewMode_button.setVisibility(View.VISIBLE);

            // show previous/next buttons for image, not for video
            if (UtilVideo.hasVideoExtension(pictureUri, act) && !UtilVideo.hasMediaControlWidget) // for video
            {
                System.out.println("NoteUi / constructor / for video");
                show_picViewUI_previous_next(true, position);
            } else if (UtilImage.hasImageExtension(pictureUri, act) && (UtilVideo.mVideoView == null))// for image
            {
                System.out.println("NoteUi / constructor / for image");
                show_picViewUI_previous_next(true, position);
            }
        } else {
            show_picViewUI_previous_next(false, 0);
            picView_viewMode_button.setVisibility(View.GONE);
        }

        // show seek bar for video only
        if (!UtilVideo.hasMediaControlWidget) {
            if (UtilVideo.hasVideoExtension(pictureUri, act)) {
                MediaPlayer mp = MediaPlayer.create(act, Uri.parse(pictureUri));

                if (mp != null) {
                    videoFileLength_inMilliSeconds = mp.getDuration();
                    mp.release();
                }

                primaryVideoSeekBarProgressUpdater(pager, position, UtilVideo.mPlayVideoPosition, pictureUri);
            } else {
                videoView_currPosition.setVisibility(View.GONE);
                videoView_seekBar.setVisibility(View.GONE);
                videoView_fileLength.setVisibility(View.GONE);
            }
        }

        showSeekBarProgress = true;
    }
}

From source file:com.eyekabob.EventInfo.java

protected void loadEvent(JSONObject response) {
    try {//  w  w w .  ja v a2s  .c o  m
        JSONObject jsonEvent = response.getJSONObject("event");

        artists = new ArrayList<String>();
        title = jsonEvent.getString("title");
        JSONObject jsonAllArtists = jsonEvent.getJSONObject("artists");
        headliner = jsonAllArtists.getString("headliner");
        Object artistObj = jsonAllArtists.get("artist");
        JSONArray jsonOpeners = new JSONArray();
        if (artistObj instanceof JSONArray) {
            jsonOpeners = (JSONArray) artistObj;
        }
        for (int i = 0; i < jsonOpeners.length(); i++) {
            String artistName = jsonOpeners.getString(i);
            if (!headliner.equals(artistName)) {
                artists.add(artistName);
            }
        }

        JSONObject jsonVenue = jsonEvent.getJSONObject("venue");
        venue = jsonVenue.optString("name");
        venueCity = jsonVenue.optString("city");
        venueStreet = jsonVenue.optString("street");
        venueUrl = jsonVenue.optString("url");
        startDate = EyekabobHelper.LastFM.toReadableDate(jsonEvent.getString("startDate"));
        JSONObject image = EyekabobHelper.LastFM.getLargestJSONImage(jsonEvent.getJSONArray("image"));
        imageUrl = image.getString("#text");
    } catch (JSONException e) {
        Log.e(getClass().getName(), "", e);
    }

    try {
        new EventImageTask().execute(new URL(imageUrl));
    } catch (MalformedURLException e) {
        Log.e(getClass().getName(), "Bad image URL [" + imageUrl + "]", e);
    }

    TextView titleView = (TextView) findViewById(R.id.infoMainHeader);
    titleView.setText(title);

    TextView headlinerView = (TextView) findViewById(R.id.infoSubHeaderOne);
    // TODO: I18N
    headlinerView.setText("Headlining: " + headliner);

    TextView dateTimeView = (TextView) findViewById(R.id.infoSubHeaderTwo);
    dateTimeView.setText(startDate);

    if (!startDate.equals("")) {
        Button tixButton = (Button) findViewById(R.id.infoTicketsButton);
        tixButton.setVisibility(View.VISIBLE);
    }

    LinearLayout artistsView = (LinearLayout) findViewById(R.id.infoFutureEventsContent);
    TextView alsoPerformingView = (TextView) findViewById(R.id.infoFutureEventsHeader);
    if (!artists.isEmpty()) {
        // TODO: I18N
        alsoPerformingView.setText("Also Performing:");
        for (String artist : artists) {
            TextView row = new TextView(this);
            row.setTextColor(Color.WHITE);
            row.setText(artist);
            row.setPadding(20, 0, 0, 20); // Left and bottom padding
            artistsView.addView(row);
        }
    }

    String venueDesc = "";
    TextView venueView = (TextView) findViewById(R.id.infoEventVenue);
    // TODO: Padding instead of whitespace
    venueDesc += "         " + venue;
    if (!venueCity.equals("") && !venueStreet.equals("")) {
        // TODO: I18N
        venueDesc += "\n         Address: " + venueStreet + "\n" + venueCity;
    }
    // TODO: Padding instead of whitespace
    venueDesc += "\n         " + startDate;

    TextView venueTitleView = (TextView) findViewById(R.id.infoBioHeader);
    if (!venue.equals("") || !venueCity.equals("") || !venueStreet.equals("")) {
        // TODO: I18N
        venueTitleView.setText("Venue Details:");
        View vView = findViewById(R.id.infoVenueDetails);
        vView.setVisibility(View.VISIBLE);
    } else {
        // TODO: I18N
        venueTitleView.setText("No Venue Details Available");
    }

    venueView.setVisibility(View.VISIBLE);
    venueView.setText(venueDesc);

    TextView websiteView = (TextView) findViewById(R.id.infoVenueWebsite);
    if (!venueUrl.equals("")) {
        // TODO: I18N
        websiteView.setVisibility(View.VISIBLE);
        websiteView.setText(Html.fromHtml("<a href=\"" + venueUrl + "\">More Information</a>"));
        websiteView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:com.box.myview.MyTopSnackBar.TSnackbar.java

/**
 * Set the action to be displayed in this {@link TSnackbar}.
 *
 * @param text     Text to display/*from   ww  w  .ja  va 2  s .  c om*/
 * @param listener callback to be invoked when the action is clicked
 */
@NonNull
public TSnackbar setAction(CharSequence text, final View.OnClickListener listener) {
    final TextView tv = mView.getActionView();
    if (TextUtils.isEmpty(text) || listener == null) {
        tv.setVisibility(View.GONE);
        tv.setOnClickListener(null);
    } else {
        tv.setVisibility(View.VISIBLE);
        tv.setText(text);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClick(view);

                dispatchDismiss(Callback.DISMISS_EVENT_ACTION);
            }
        });
    }
    return this;
}

From source file:com.microsoft.onedrive.apiexplorer.DeltaFragment.java

/**
 * Create a handler for downloaded pages
 * @return The callback to handle a fresh DeltaPage
 *//* w  ww.j av a  2s  .  c  o m*/
private ICallback<IDeltaCollectionPage> pageHandler() {
    return new DefaultCallback<IDeltaCollectionPage>(getActivity()) {
        @Override
        public void success(final IDeltaCollectionPage page) {
            final View view = getView();
            if (view == null) {
                return;
            }

            final View viewById = view.findViewById(R.id.json);
            if (viewById == null) {
                return;
            }

            if (mCurrentPagesCount.incrementAndGet() == MAX_PAGE_COUNT) {
                Toast.makeText(getActivity(), R.string.max_pages_downloaded, Toast.LENGTH_LONG).show();
                return;
            }

            final TextView jsonView = (TextView) viewById;
            final CharSequence originalText = jsonView.getText();
            final StringBuilder sb = new StringBuilder(originalText);
            for (final Item i : page.getCurrentPage()) {
                try {
                    final int indentSpaces = 3;
                    sb.append(new JSONObject(i.getRawObject().toString()).toString(indentSpaces));
                } catch (final JSONException ignored) {
                    Log.e(getClass().getName(), "Unable to parse the response body to json");
                }
                sb.append("\n");
            }

            if (page.getCurrentPage().size() == 0) {
                sb.append(getString(R.string.empty_delta));
            }
            jsonView.setText(sb.toString());
            view.findViewById(android.R.id.progress).setVisibility(View.INVISIBLE);
            jsonView.setVisibility(View.VISIBLE);
            if (page.getNextPage() != null) {
                page.getNextPage().buildRequest().get(pageHandler());
            }
            final JsonElement deltaToken = page.getRawObject().get("@delta.token");
            if (deltaToken != null) {
                getDeltaInfo().edit().putString(mItemId, deltaToken.getAsString()).commit();
            }
        }
    };
}

From source file:com.cqyw.smart.widget.viewpaper.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    TextView unreadLbl = null;
    //        ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    if (actionbarTabLayout != null) {
        if (index == 0) {
            unreadLbl = (TextView) actionbarTabLayout.findViewById(R.id.tab_new_msg_label); // Kyrong
        } else if (index == 1) {
            unreadLbl = (TextView) actionbarTabLayout.findViewById(R.id.tab_new_friend_label);// Kyrong
        }/*from www  .  j  av  a2  s . c om*/
    }

    if (item == null || unreadLbl == null/* || indicatorView == null*/) {
        unreadLbl.setVisibility(View.GONE);
        //            indicatorView.setVisibility(View.GONE);
        return;
    }
    int unread = item.unread();
    boolean indicator = item.indicator();
    unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    //        indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    //        if (unread > 0) {
    //            unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread)));
    //        }
}