Example usage for android.widget TextView setTag

List of usage examples for android.widget TextView setTag

Introduction

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

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

private int layoutPunctuationsAndReturnStartIndexOfMoreSuggestions(
        final PunctuationSuggestions punctuationSuggestions, final ViewGroup stripView) {
    final int countInStrip = Math.min(punctuationSuggestions.size(), PUNCTUATIONS_IN_STRIP);
    for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
        if (positionInStrip != 0) {
            // Add divider if this isn't the left most suggestion in suggestions strip.
            addDivider(stripView, mDividerViews.get(positionInStrip));
        }/*from w  w w .  j ava  2s  . c o m*/

        final TextView wordView = mWordViews.get(positionInStrip);
        final String punctuation = punctuationSuggestions.getLabel(positionInStrip);
        // {@link TextView#getTag()} is used to get the index in suggestedWords at
        // {@link SuggestionStripView#onClick(View)}.
        wordView.setTag(positionInStrip);
        wordView.setText(punctuation);
        wordView.setContentDescription(punctuation);
        wordView.setTextScaleX(1.0f);
        wordView.setCompoundDrawables(null, null, null, null);
        wordView.setTextColor(mColorAutoCorrect);
        stripView.addView(wordView);
        setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
    }
    mMoreSuggestionsAvailable = (punctuationSuggestions.size() > countInStrip);
    return countInStrip;
}

From source file:opensourceproject.kanjisteps.Practice_slides.java

public int quizByLevelOnyomi() {
    enableButtons();// w  w w  . j  av a  2  s .  c o  m
    KanjiToStudyAdapter dbAdapter = new KanjiToStudyAdapter(this);
    Cursor cursor = dbAdapter.getItemsByLevelRandom(level_marker, 0);
    TextView txt = (TextView) findViewById(R.id.textToDisplay);
    TextView txtDblTap = (TextView) findViewById(R.id.textDoubleTap);
    txtDblTap.setOnClickListener(this);
    txtDblTap.setOnTouchListener(gestureListener);
    txtDblTap.setVisibility(View.INVISIBLE);

    String temp = "";
    if (cursor.moveToNext()) {
        int indexOfKanji = cursor.getColumnIndex(dbAdapter.myKanjiDb.COLUMN_KANJI);
        temp = cursor.getString(indexOfKanji);

        txt.setText(temp);
        txt.setTextSize(50);
        txt.setTextColor(Color.GRAY);
        txt.setTag("2"); //2 means japanese READING
        populateButtonChoicesOnyomi(cursor, dbAdapter);
        return 0;
    } else {
        /*
        txt.setTextSize(20);
        txt.setTextColor(Color.GRAY);
        txt.setText("You don't have any items to review yet! Check back later.");
        resetButtons();
        */
        return 1;
    }
}

From source file:opensourceproject.kanjisteps.Practice_slides.java

public int quizByLevelMeaning() {
    enableButtons();/*from   w  ww. j ava  2s.c  o m*/
    KanjiToStudyAdapter dbAdapter = new KanjiToStudyAdapter(this);
    Cursor cursor = dbAdapter.getItemsByLevelRandom(level_marker, 1);
    TextView txt = (TextView) findViewById(R.id.textToDisplay);
    TextView txtDblTap = (TextView) findViewById(R.id.textDoubleTap);
    txtDblTap.setOnClickListener(this);
    txtDblTap.setOnTouchListener(gestureListener);
    txtDblTap.setVisibility(View.INVISIBLE);
    String temp = "";
    if (cursor.moveToNext()) {
        int indexOfKanji = cursor.getColumnIndex(dbAdapter.myKanjiDb.COLUMN_KANJI);
        temp = cursor.getString(indexOfKanji);

        txt.setText(temp);
        txt.setTextSize(50);
        txt.setTextColor(Color.GRAY);
        txt.setTag("1"); //1 means ENGLISH meaning
        populateButtonChoicesMeaning(cursor, dbAdapter);
        return 0;
    } else {
        /*
        txt.setText("You don't have any items to review yet! Check back later.");
        txt.setTextSize(20);
        txt.setTextColor(Color.GRAY);
                
        resetButtons();
        */
        return 1; //display notice that there is nothing to review yet.
    }

}

From source file:org.opensilk.common.ui.widget.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    final int currentPosition = mViewPager.getCurrentItem();
    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*from w w w.  ja  va  2 s.  co m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTag("title");
        if (i == currentPosition) {
            tabTitleView.setTextColor(mSelectedTextColor);
        }
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3,
        int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;
    localTextView.setTextSize(f);//from   w  w  w  .j ava 2  s  .c  o m

    localTextView.setGravity(Gravity.CENTER);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); // touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(true);
    Resources localResources = getResources();
    Drawable localDrawable = null;
    if (paramInt4 == 0 && paramInt3 >= 0) {// 
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
}

From source file:mp.teardrop.LibraryPagerAdapter.java

void updateLimiterViews() {

    LinearLayout limiterViews = (LinearLayout) mContainingLayouts[mTabOrder[mCurrentPage]]
            .findViewById(R.id.new_limiter_layout);

    if (limiterViews == null) {
        return;//ww  w  .j a v a  2 s  .  c o m
    }

    limiterViews.removeAllViews();

    Limiter limiterData = getCurrentLimiter();

    if (mTabOrder[mCurrentPage] == MediaUtils.TYPE_FILE || mTabOrder[mCurrentPage] == MediaUtils.TYPE_DROPBOX) { //always create an element representing the root directory
        TextView textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null);
        textView1.setText(R.string.root_directory);
        textView1.setTag(LibraryActivity.TAG_DELIMITER_ROOT); //used to handle click event properly
        textView1.setOnClickListener(mActivity);
        limiterViews.addView(textView1);
        mLimiterScroller.setVisibility(View.VISIBLE);
    } else if (mTabOrder[mCurrentPage] == MediaUtils.TYPE_UNIFIED) {
        // always create a link to the root of the library
        TextView textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null);
        textView1.setText(R.string.library);
        textView1.setTag(LibraryActivity.TAG_DELIMITER_ROOT); //used to handle click event properly
        textView1.setOnClickListener(mActivity);
        limiterViews.addView(textView1);

        //create a link to all albums, artists or songs if applicable
        if (limiterData != null && (limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_ALBUMS
                && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_ARTISTS
                && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_SONGS
                && limiterData.type != UnifiedAdapter.ITEM_TYPE_MORE_PLAYLISTS)) {
            textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null);
            textView1.setText(R.string.limiter_separator);
            textView1.setTextColor(0xa3ffffff);
            limiterViews.addView(textView1);

            textView1 = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null);

            switch (limiterData.type) {
            case UnifiedAdapter.ITEM_TYPE_ARTIST:
                textView1.setText(R.string.artists);
                textView1.setTag(LibraryActivity.TAG_ARTISTS_ROOT);
                break;
            case UnifiedAdapter.ITEM_TYPE_ALBUM:
                textView1.setText(R.string.albums);
                textView1.setTag(LibraryActivity.TAG_ALBUMS_ROOT);
                break;
            case UnifiedAdapter.ITEM_TYPE_PLAYLIST:
                textView1.setText(R.string.playlists);
                textView1.setTag(LibraryActivity.TAG_PLAYLISTS_ROOT);
                break;
            }

            textView1.setOnClickListener(mActivity);
            limiterViews.addView(textView1);
        }
    }

    if (limiterData != null) {
        String[] limiter = limiterData.names;

        for (int i = 0; i != limiter.length; ++i) {
            TextView textView = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view,
                    null);
            textView.setText(R.string.limiter_separator);
            textView.setTextColor(0xa3ffffff);
            limiterViews.addView(textView);

            textView = (TextView) mActivity.getLayoutInflater().inflate(R.layout.limiter_text_view, null);
            textView.setText(limiter[i]);
            textView.setTag(i);
            textView.setOnClickListener(mActivity);
            limiterViews.addView(textView);
        }
    }

}

From source file:org.mythdroid.activities.Guide.java

/**
 * Generate a TableRow from the provided Channel
 * @param ch Channel to generate a row for
 * @return populated TableRow representing the channel
 *///from  w  w  w  . jav  a  2 s .  c o m
@SuppressLint("DefaultLocale")
private TableRow getRowFromChannel(Channel ch) {

    final TableRow row = new TableRow(this);
    row.setLayoutParams(rowLayout);

    TextView tv = new TextView(this);
    tv.setBackgroundColor(0xffe0e0f0);
    tv.setTextColor(0xff202020);
    tv.setPadding(4, 4, 4, 4);
    tv.setMaxLines(2);
    tv.setTag(ch.ID);
    tv.setText(ch.num + " " + ch.callSign); //$NON-NLS-1$
    tv.setOnClickListener(chanClickListener);
    tv.setOnLongClickListener(chanLongClickListener);
    tv.setLayoutParams(chanLayout);

    row.addView(tv);

    LayoutParams layout = null;

    Program[] progs = ch.programs.toArray(new Program[ch.programs.size()]);
    int numprogs = progs.length;

    for (int i = 0; i < numprogs; i++) {

        if (progs[i].StartTime.equals(later))
            continue;

        tv = new TextView(this);
        layout = new LayoutParams(this, null);
        layout.topMargin = layout.bottomMargin = layout.leftMargin = layout.rightMargin = 1;
        layout.height = rowHeight;

        String cat = catPat.matcher(progs[i].Category.toLowerCase()).replaceAll(""); //$NON-NLS-1$

        try {
            tv.setBackgroundColor(Category.valueOf(cat).color());
        } catch (IllegalArgumentException e) {
            tv.setBackgroundColor(Category.unknown.color());
        }

        tv.setTextColor(0xfff0f0f0);
        tv.setPadding(4, 4, 4, 4);
        tv.setMaxLines(2);
        tv.setText(progs[i].Title);
        setStatusDrawable(tv, progs[i]);

        int width = setLayoutParams(layout, progs[i]) * colWidth;
        if (width < 1)
            continue;

        tv.setWidth(width);
        tv.setLayoutParams(layout);
        tv.setTag(progs[i]);
        tv.setOnClickListener(progClickListener);
        row.addView(tv);

    }

    return row;

}

From source file:liqui.droid.activity.Base.java

/**
 * Creates the breadcrumb.//from w  w  w.  jav a2  s . c  o m
 *
 * @param subTitle the sub title
 * @param breadCrumbHolders the bread crumb holders
 */
public void createBreadcrumb(String subTitle, BreadCrumbHolder... breadCrumbHolders) {
    if (breadCrumbHolders != null) {
        LinearLayout llPart = (LinearLayout) this.findViewById(R.id.ll_part);
        for (int i = 0; i < breadCrumbHolders.length; i++) {
            TextView tvBreadCrumb = new TextView(getApplication());
            SpannableString part = new SpannableString(breadCrumbHolders[i].getLabel());
            part.setSpan(new UnderlineSpan(), 0, part.length(), 0);
            tvBreadCrumb.append(part);
            tvBreadCrumb.setTag(breadCrumbHolders[i]);
            tvBreadCrumb.setBackgroundResource(R.drawable.default_link);
            tvBreadCrumb.setTextAppearance(getApplication(), R.style.default_text_small);
            tvBreadCrumb.setSingleLine(true);
            tvBreadCrumb.setOnClickListener(new OnClickBreadCrumb(this));

            llPart.addView(tvBreadCrumb);

            if (i < breadCrumbHolders.length - 1) {
                TextView slash = new TextView(getApplication());
                slash.setText(" / ");
                slash.setTextAppearance(getApplication(), R.style.default_text_small);
                llPart.addView(slash);
            }
        }
    }

    ScrollingTextView tvSubtitle = (ScrollingTextView) this.findViewById(R.id.tv_subtitle);
    tvSubtitle.setText(subTitle);
}

From source file:com.nadmm.airports.afd.AirportDetailsFragment.java

protected void addAwosRow(LinearLayout layout, String id, String name, String type, String freq, String phone,
        float distance, float bearing, final Runnable runnable) {
    StringBuilder sb = new StringBuilder();
    sb.append(id);//from  ww  w.j a  v  a 2  s  .  c o  m
    if (name != null && !name.isEmpty()) {
        sb.append(" - ");
        sb.append(name);
    }
    String label1 = sb.toString();

    sb.setLength(0);
    if (freq != null && !freq.isEmpty()) {
        try {
            sb.append(FormatUtils.formatFreq(Float.valueOf(freq)));
        } catch (NumberFormatException ignored) {
        }
    }
    String value1 = sb.toString();

    sb.setLength(0);
    sb.append(type);
    if (mIcaoCode.equals(id)) {
        sb.append(", On-site");
    } else {
        sb.append(String.format(Locale.US, ", %.1f NM %s", distance, GeoUtils.getCardinalDirection(bearing)));
    }
    String label2 = sb.toString();

    View row = addClickableRow(layout, label1, value1, label2, phone, runnable);

    TextView tv = (TextView) row.findViewById(R.id.item_label);
    tv.setTag(id);
    mAwosViews.add(tv);
    // Make phone number clickable
    tv = (TextView) row.findViewById(R.id.item_extra_value);
    if (tv.getText().length() > 0) {
        makeClickToCall(tv);
    }
}

From source file:com.antonborries.bulktask.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from w  w  w  .  j a  v  a  2 s .  co  m
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTag("titleView_" + String.valueOf(i));
        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }

        tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector));
        tabTitleView.setTextSize(14);
    }
}