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:Main.java

public static void setTitle(TextView titleTv, int titleColor, int titleTextSize, int messageColor,
        int messageTextSize, CharSequence title, CharSequence message) {
    titleTv.setMinHeight(titleTextSize * 3);

    if (!TextUtils.isEmpty(title) && TextUtils.isEmpty(message)) {
        titleTv.setTextColor(titleColor);
        titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
        titleTv.getPaint().setFakeBoldText(true);
        titleTv.setText(title);//from  w w  w .jav  a 2  s .c  om
    } else if (TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) {
        titleTv.setTextColor(messageColor);
        titleTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, messageTextSize);
        titleTv.setText(message);
    } else if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) {
        SpannableString titleSs = new SpannableString(title + "\n" + message);
        titleSs.setSpan(new ForegroundColorSpan(titleColor), 0, title.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new AbsoluteSizeSpan(titleTextSize), 0, title.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new StyleSpan(Typeface.BOLD), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        titleSs.setSpan(new ForegroundColorSpan(messageColor), title.length(), titleSs.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleSs.setSpan(new AbsoluteSizeSpan(messageTextSize), title.length(), titleSs.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        titleTv.setText(titleSs);
        titleTv.setLineSpacing(0.0f, 1.2f);
    } else {
        titleTv.setVisibility(View.GONE);
    }
}

From source file:cm.confide.ex.chips.RecipientAlternatesAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    int position = cursor.getPosition();

    TextView display = (TextView) view.findViewById(android.R.id.title);
    ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
    RecipientEntry entry = getRecipientEntry(position);
    if (position == 0) {
        display.setText(cursor.getString(Queries.Query.NAME));
        display.setVisibility(View.VISIBLE);
        // TODO: see if this needs to be done outside the main thread
        // as it may be too slow to get immediately.
        imageView.setImageURI(entry.getPhotoThumbnailUri());
        imageView.setVisibility(View.VISIBLE);
    } else {/*w ww  .j  a  v  a2 s. co m*/
        display.setVisibility(View.GONE);
        imageView.setVisibility(View.GONE);
    }
    TextView destination = (TextView) view.findViewById(android.R.id.text1);
    destination.setText(cursor.getString(Queries.Query.DESTINATION));

    TextView destinationType = (TextView) view.findViewById(android.R.id.text2);
    if (destinationType != null) {
        destinationType.setText(
                mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE),
                        cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase());
    }
}

From source file:com.chatwingsdk.fragments.CommunicationDrawerFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    TextView unreadCountView;
    switch (loader.getId()) {
    case LOADER_ID_COUNT_CONVERSATIONS_MESSAGES_UNREAD:
        unreadCountView = mConversationsUnreadCountView;
        break;// w  ww .  j ava  2s . com
    case LOADER_ID_CHATBOXES:
        unreadCountView = mCategoriesUnreadCountView;
        break;
    default:
        return;
    }

    if (data == null || data.getCount() == 0 || !data.moveToFirst()) {
        unreadCountView.setVisibility(View.GONE);
        return;
    }

    int columnIndex = data.getColumnIndexOrThrow(COLUMN_NAME_SUM_UNREAD_COUNT);
    int unreadCount = data.getInt(columnIndex);
    if (unreadCount == 0) {
        unreadCountView.setVisibility(View.GONE);
    } else {
        unreadCountView.setText(Integer.toString(unreadCount));
        unreadCountView.setVisibility(View.VISIBLE);
    }
}

From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java

private void showCurrentFileName(String newFileName) {
    TextView txtFilename = (TextView) rootView.findViewById(R.id.simpleview_txtfilepath);
    if (newFileName == null || newFileName.length() <= 0) {
        txtFilename.setText("");
        txtFilename.setVisibility(View.INVISIBLE);
        return;//from  w  w w  .j  av  a2  s  . c  o m
    }

    txtFilename.setVisibility(View.VISIBLE);
    txtFilename.setText(Html.fromHtml("<em>" + preferenceHelper.getGpsLoggerFolder() + "/<strong><br />"
            + Session.getCurrentFileName(getActivity()) + "</strong></em>"));

    Files.setFileExplorerLink(txtFilename,
            Html.fromHtml("<em><font color='blue'><u>" + preferenceHelper.getGpsLoggerFolder() + "</u></font>"
                    + "/<strong><br />" + Session.getCurrentFileName(getActivity()) + "</strong></em>"),
            preferenceHelper.getGpsLoggerFolder(), context);

}

From source file:com.androzic.About.java

private void updateAboutInfo(final View view) {
    // version/*ww w.j av a  2  s.  c om*/
    String versionName = null;
    int versionBuild = 0;
    try {
        versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionName;
        versionBuild = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionCode;
    } catch (NameNotFoundException ex) {
        versionName = "unable to retreive version";
    }
    final TextView version = (TextView) view.findViewById(R.id.version);
    version.setText(getString(R.string.version, versionName, versionBuild));

    // home links
    StringBuilder links = new StringBuilder();
    links.append("<a href=\"");
    links.append(": http://androzic.com");
    links.append("\">");
    links.append(getString(R.string.homepage));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.faquri));
    links.append("\">");
    links.append(getString(R.string.faq));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.featureuri));
    links.append("\">");
    links.append(getString(R.string.feedback));
    links.append("</a>");
    final TextView homelinks = (TextView) view.findViewById(R.id.homelinks);
    homelinks.setText(Html.fromHtml(links.toString()));
    homelinks.setMovementMethod(LinkMovementMethod.getInstance());

    // community links
    StringBuilder communities = new StringBuilder();
    communities.append("<a href=\"");
    communities.append(getString(R.string.googleplusuri));
    communities.append("\">");
    communities.append(getString(R.string.googleplus));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.facebookuri));
    communities.append("\">");
    communities.append(getString(R.string.facebook));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.twitteruri));
    communities.append("\">");
    communities.append(getString(R.string.twitter));
    communities.append("</a>");
    final TextView communitylinks = (TextView) view.findViewById(R.id.communitylinks);
    communitylinks.setText(Html.fromHtml(communities.toString()));
    communitylinks.setMovementMethod(LinkMovementMethod.getInstance());

    // donations
    StringBuilder donations = new StringBuilder();
    donations.append("<a href=\"");
    donations.append(getString(R.string.playuri));
    donations.append("\">");
    donations.append(getString(R.string.donate_google));
    donations.append("</a><br /><a href=\"");
    donations.append(getString(R.string.paypaluri));
    donations.append("\">");
    donations.append(getString(R.string.donate_paypal));
    donations.append("</a>");

    final TextView donationlinks = (TextView) view.findViewById(R.id.donationlinks);
    donationlinks.setText(Html.fromHtml(donations.toString()));
    donationlinks.setMovementMethod(LinkMovementMethod.getInstance());

    Androzic application = Androzic.getApplication();
    if (application.isPaid) {
        view.findViewById(R.id.donations).setVisibility(View.GONE);
        view.findViewById(R.id.donationtext).setVisibility(View.GONE);
        donationlinks.setVisibility(View.GONE);
    }

    // license
    final SpannableString message = new SpannableString(
            Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>")));
    Linkify.addLinks(message, Linkify.WEB_URLS);
    final TextView license = (TextView) view.findViewById(R.id.license);
    license.setText(message);
    license.setMovementMethod(LinkMovementMethod.getInstance());

    // credits
    String[] names = getResources().getStringArray(R.array.credit_names);
    String[] merits = getResources().getStringArray(R.array.credit_merits);

    StringBuilder credits = new StringBuilder();
    for (int i = 0; i < names.length; i++) {
        credits.append("<b>");
        credits.append(merits[i]);
        credits.append("</b> &mdash; ");
        credits.append(names[i]);
        credits.append("<br />");
    }

    final TextView creditlist = (TextView) view.findViewById(R.id.credits);
    creditlist.setText(Html.fromHtml(credits.toString()));

    // dedication
    final TextView dedicated = (TextView) view.findViewById(R.id.dedicated);
    dedicated.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clicks = 1;
            dedicated.setVisibility(View.GONE);
            View photo = view.findViewById(R.id.photo);
            photo.setVisibility(View.VISIBLE);
            photo.setOnClickListener(redirect);
        }
    });
}

From source file:com.gh4a.activities.IssueActivity.java

private void fillData() {
    // set details inside listview header
    ImageView ivGravatar = (ImageView) mListHeaderView.findViewById(R.id.iv_gravatar);
    AvatarHandler.assignAvatar(ivGravatar, mIssue.getUser());
    ivGravatar.setOnClickListener(this);

    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    boolean closed = Constants.Issue.STATE_CLOSED.equals(mIssue.getState());
    int stateTextResId = closed ? R.string.closed : R.string.open;
    int stateColorAttributeId = closed ? R.attr.colorIssueClosed : R.attr.colorIssueOpen;

    tvState.setText(getString(stateTextResId).toUpperCase(Locale.getDefault()));
    transitionHeaderToColor(stateColorAttributeId,
            closed ? R.attr.colorIssueClosedDark : R.attr.colorIssueOpenDark);
    UiUtils.trySetListOverscrollColor(mRecyclerView, UiUtils.resolveColor(this, stateColorAttributeId));

    TextView tvExtra = (TextView) mListHeaderView.findViewById(R.id.tv_extra);
    tvExtra.setText(ApiHelpers.getUserLogin(this, mIssue.getUser()));

    TextView tvTimestamp = (TextView) mListHeaderView.findViewById(R.id.tv_timestamp);
    tvTimestamp.setText(StringUtils.formatRelativeTime(this, mIssue.getCreatedAt(), true));

    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    tvTitle.setText(mIssue.getTitle());/* w  w  w  .  j av a  2  s. c  om*/

    String body = mIssue.getBodyHtml();
    TextView descriptionView = (TextView) mListHeaderView.findViewById(R.id.tv_desc);
    if (!StringUtils.isBlank(body)) {
        body = HtmlUtils.format(body).toString();
        mImageGetter.bind(descriptionView, body, mIssue.getNumber());
    }
    descriptionView.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);

    View milestoneGroup = mListHeaderView.findViewById(R.id.milestone_container);
    if (mIssue.getMilestone() != null) {
        TextView tvMilestone = (TextView) mListHeaderView.findViewById(R.id.tv_milestone);
        tvMilestone.setText(mIssue.getMilestone().getTitle());
        milestoneGroup.setVisibility(View.VISIBLE);
    } else {
        milestoneGroup.setVisibility(View.GONE);
    }

    View assigneeGroup = mListHeaderView.findViewById(R.id.assignee_container);
    if (mIssue.getAssignee() != null) {
        TextView tvAssignee = (TextView) mListHeaderView.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin());

        ImageView ivAssignee = (ImageView) mListHeaderView.findViewById(R.id.iv_assignee);
        AvatarHandler.assignAvatar(ivAssignee, mIssue.getAssignee());
        ivAssignee.setOnClickListener(this);
        assigneeGroup.setVisibility(View.VISIBLE);
    } else {
        assigneeGroup.setVisibility(View.GONE);
    }

    List<Label> labels = mIssue.getLabels();
    View labelGroup = mListHeaderView.findViewById(R.id.label_container);
    if (labels != null && !labels.isEmpty()) {
        TextView labelView = (TextView) mListHeaderView.findViewById(R.id.labels);
        SpannableStringBuilder builder = new SpannableStringBuilder();

        for (Label label : labels) {
            int pos = builder.length();
            IssueLabelSpan span = new IssueLabelSpan(this, label, true);
            builder.append(label.getName());
            builder.setSpan(span, pos, pos + label.getName().length(), 0);
        }
        labelView.setText(builder);
        labelGroup.setVisibility(View.VISIBLE);
    } else {
        labelGroup.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mListHeaderView.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    } else {
        tvPull.setVisibility(View.GONE);
    }

    mHeader.setVisibility(View.VISIBLE);
    updateFabVisibility();
    updateCommentLockState();
}

From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java

public void setCountNumber(int tabIndex, int count) {
    if (tabIndex >= tabsContainer.getChildCount()
            || !(tabsContainer.getChildAt(tabIndex) instanceof LinearLayout)) {
        return;/*ww w  .  ja  v a 2 s.c  o m*/
    }
    TextView countView = (TextView) ((LinearLayout) tabsContainer.getChildAt(tabIndex)).getChildAt(1);
    countView.setText(count + "");
    countView.setVisibility(View.VISIBLE);
}

From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label);

    if (item == null || unreadLbl == null || indicatorView == null) {
        unreadLbl.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;// w  w  w.j a va  2  s  .  co  m
    }
    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)));
    }
}

From source file:com.anysoftkeyboard.ui.SendBugReportUiActivity.java

@Override
protected void onStart() {
    super.onStart();
    TextView crashTypeView = (TextView) findViewById(R.id.ime_crash_type);
    Intent callingIntent = getIntent();//ww w  . ja v  a 2  s  .  c o m
    mCrashReportDetails = callingIntent.getParcelableExtra(EXTRA_KEY_BugReportDetails);
    if (mCrashReportDetails == null) {
        if (BuildConfig.DEBUG)
            throw new IllegalArgumentException(
                    "Activity started without " + EXTRA_KEY_BugReportDetails + " extra!");
        finish();
    } else {
        if (mCrashReportDetails.throwable == null || (!BuildConfig.DEBUG)) {
            /*not showing the type of crash in RELEASE mode*/
            crashTypeView.setVisibility(View.GONE);
        } else {
            Throwable throwable = mCrashReportDetails.throwable;
            String typeText = throwable.getClass().getName();
            if (!TextUtils.isEmpty(throwable.getMessage()))
                typeText += ": " + throwable.getMessage();

            StackTraceElement[] stackTrace = throwable.getStackTrace();
            if (stackTrace != null && stackTrace.length > 0) {
                typeText += "\n";
                typeText += "Thrown at " + stackTrace[0].toString();
                for (int i = 1; i < Math.min(3, stackTrace.length); i++) {
                    typeText += "\n" + stackTrace[i].toString();
                }
            }

            crashTypeView.setText(typeText);
        }
    }
}

From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java

/**
 * Set number showing in number tab.//from w  ww .  j  ava 2 s.com
 * 
 * @param number number to show
 */
public void setNumber(int position, int number) {
    if (position > mTabCount) {
        throw new IllegalArgumentException("the position is not valid");
    }

    if (!(mViewPager.getAdapter() instanceof NumTabProvider)) {
        throw new IllegalAccessError(
                "the tab is not number tab, " + "the adapter should implement NumTabProvider");
    }

    /* update the number text */
    View v = mTabsContainer.getChildAt(position);
    if (v instanceof LinearLayout) {
        View tabNum = ((LinearLayout) v).getChildAt(1);
        if (tabNum instanceof TextView) {
            TextView textNum = (TextView) tabNum;
            if (number == 0) {
                textNum.setVisibility(View.GONE);
            } else {
                textNum.setVisibility(View.VISIBLE);
                textNum.setText(Integer.toString(number));
            }
        }
    }
}