Example usage for android.widget TextView getText

List of usage examples for android.widget TextView getText

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public CharSequence getText() 

Source Link

Document

Return the text that TextView is displaying.

Usage

From source file:com.hua.weget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);
        selectedTabTextColor = context.getResources().getColor(R.color.homefragment_top_title_color);
        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            tab.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(mDrawableIds[i]),
                    null, null, null);//from  w  w  w  .  j  ava  2s . com

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setCompoundDrawablesWithIntrinsicBounds(
                        context.getResources().getDrawable(mDrawableIdsSleect[i]), null, null, null);
            }
        }
    }

}

From source file:com.collcloud.frame.viewpager.PagerSlidingTabStrip.java

public void updateTabStyles(int curPosition) {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof RelativeLayout) {
            RelativeLayout rL = (RelativeLayout) v;
            TextView tab = (TextView) rL.getChildAt(0);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);

            if (curPosition == i) {
                tab.setTextColor(pstsTextHighLightColor);
            } else {
                tab.setTextColor(tabTextColor);
            }/*from  www .j a  v a2s  .c o  m*/

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.heqi.kharazim.ui.fragment.tab.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, 0, tabPadding, 0);

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (tabTextColorStateList != null) {
                tab.setTextColor(tabTextColorStateList);
            } else {
                tab.setTextColor(tabTextColor);
            }//from   w ww.  java  2 s  . c o  m
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are
            // on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.homechart.app.commont.matertab.MaterialTabs.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.mt_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTextColor(tabTextColorUnselected);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a pre-ICS-build.
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }//  w  ww. ja va 2 s  .  c  o  m
            }
        }
    }
}

From source file:com.flipzu.flipzu.Recorder.java

@Override
public void onCommentsReceived(Hashtable<String, String>[] comments) {
    debug.logV(TAG, "onCommentsReceived");

    final LinearLayout cc = (LinearLayout) findViewById(R.id.comments_container);

    /* cleanup comments first */
    cc.removeAllViews();/*  ww w  . j a  va  2  s.c o m*/

    /* get pixel values for various DIPs */
    final float scale = getResources().getDisplayMetrics().density;
    //      final int pixel_10 = 10 / (int) (scale + 0.5f);
    final int pixel_5 = 5 / (int) (scale + 0.5f);
    //      final int pixel_30 = 30 / (int) (scale + 0.5f);
    final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    if (comments != null && comments.length > 0) {

        for (int i = 0; i < comments.length; i++) {

            LinearLayout cl = new LinearLayout(Recorder.this);
            cl.setOrientation(LinearLayout.HORIZONTAL);
            cl.setPadding(0, 0, 0, pixel_5);

            debug.logD(TAG, "Refresher comment " + comments[i]);

            /* comment */
            TextView comment_tv = new TextView(Recorder.this);
            comment_tv.setLayoutParams(params);
            comment_tv.setText(comments[i].get("username") + ": " + comments[i].get("comment"),
                    TextView.BufferType.SPANNABLE);
            comment_tv.setTextColor(Color.parseColor("#656565"));
            Spannable comment_span = (Spannable) comment_tv.getText();
            comment_span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0,
                    comment_tv.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            comment_span.setSpan(new ForegroundColorSpan(Color.parseColor("#182e5b")), 0,
                    comments[i].get("username").length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            comment_tv.setText(comment_span);
            cl.addView(comment_tv);

            cc.addView(cl);

        }

    } else {
        if (mState == recorderState.RECORDING) {
            String msg = "You're LIVE! Your broadcast can be heard at http://flipzu.com/" + mUser.getUsername();
            showFlipzuTipsOffline(cc, params, msg);
        } else {
            String msg = "Pick a good and descriptive broadcast title. A great title will attract more listeners!";
            showFlipzuTipsOffline(cc, params, msg);
            msg = "You can disable sharing in Twitter and Facebook by clicking the logo buttons. This is great for testing.";
            showFlipzuTipsOffline(cc, params, msg);
            msg = "Press the \"Start Broadcast\" button and let them hear you!";
            showFlipzuTipsOffline(cc, params, msg);
        }
    }
}

From source file:com.astuetz.PagerSlidingTriangleStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            //#####??######
            //?item  ??
            tab.setTextColor(pager.getCurrentItem() == i ? tabSelectedTextColor : tabNormalTextColor);
            //###################

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*w w w .j a  v  a  2  s .c  o m*/
            }
        }
    }

}

From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        //            v.setBackgroundResource(tabBackgroundColor != 0 ? tabBackgroundColor : tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());

        if (v instanceof TextView) {
            TextView tabText = (TextView) v.findViewById(R.id.psts_tab_title);

            if (tabText != null) {
                tabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
                // pre-ICS-build
                if (textAllCaps) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        tabText.setAllCaps(true);
                    } else {
                        tabText.setText(tabText.getText().toString().toUpperCase(locale));
                    }//from   w  w w . jav  a2  s.com
                }
            }
        }

    }
}

From source file:com.example.view.astuetz.PagerSlidingTabStrip.java

@SuppressLint("NewApi")
private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            android.widget.LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0,
                    LayoutParams.MATCH_PARENT, 1f);
            tab.setLayoutParams(layoutParams);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//from  w  ww  .  j  a  v a 2  s  .co m
            }
        }
    }

}

From source file:com.flipzu.flipzu.Player.java

private void displayComment(Hashtable<String, String> comment) {
    if (comment == null)
        return;/*from  w  w  w.  j ava2  s  .c  o m*/

    final LinearLayout com_layout = (LinearLayout) findViewById(R.id.comments_layout);
    TextView comment_tv = new TextView(Player.this);
    comment_tv.setText(comment.get("username") + ": " + comment.get("comment"), TextView.BufferType.SPANNABLE);
    comment_tv.setTextColor(Color.parseColor("#656565"));
    Spannable comment_span = (Spannable) comment_tv.getText();
    comment_span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, comment_tv.getText().length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    comment_span.setSpan(new ForegroundColorSpan(Color.parseColor("#597490")), 0,
            comment.get("username").length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    comment_tv.setText(comment_span);
    com_layout.addView(comment_tv);
}

From source file:com.csform.android.uiapptemplate.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*  w  ww  . ja  va 2 s .  c o  m*/
            }
        }
    }
}