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.hm.library.resource.tabstrip.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            try {
                TextView tab = (TextView) v;
                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) {
                        ((TextView) tab).setAllCaps(true);
                    } else {
                        tab.setText(tab.getText().toString().toUpperCase(locale));
                    }/*from w  w  w .  j  a  va2  s.c o  m*/
                }
                if (i == selectedPosition) {
                    tab.setTextColor(selectedTabTextColor);
                    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                    tab.getPaint().setFakeBoldText(true);
                } else {
                    tab.getPaint().setFakeBoldText(false);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}

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

public void showFlipzuTipsOffline(LinearLayout cc, LayoutParams params, String msg) {
    final float scale = getResources().getDisplayMetrics().density;
    final int pixel_5 = 5 / (int) (scale + 0.5f);

    LinearLayout cl = new LinearLayout(Recorder.this);
    cl.setOrientation(LinearLayout.HORIZONTAL);
    cl.setPadding(0, 0, 0, pixel_5);//  w w w  .  ja va  2  s . c  o  m

    /* comment */
    String tips_username = "Flipzu Tips";

    TextView comment_tv = new TextView(Recorder.this);
    comment_tv.setLayoutParams(params);
    comment_tv.setText(tips_username + ": " + msg, 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, tips_username.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    comment_tv.setText(comment_span);
    cl.addView(comment_tv);

    cc.addView(cl);
}

From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java

private void clipboard(TextView tv) {
    int which;/*from w ww  .  j  a  va 2  s . c om*/
    switch (tv.getId()) {
    case txt_request_url:
        which = req_url;
        break;
    case txt_response_headers:
        which = response_headers;
        break;
    case txt_response_body:
        which = response_body;
        break;
    default:
        which = UNSET;
    }
    String what = which == UNSET ? "" : getString(which) + " ";
    what += getString(clippy);
    Toast.makeText(getActivity(), what, Toast.LENGTH_SHORT).show();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // old way
        ClipboardManager clipboardManager = (ClipboardManager) getActivity()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setText(tv.getText());
    } else {
        clipboard11(tv);
    }
}

From source file:com.ipang.wansha.customview.PagerSlidingTabStrip.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);
            if (i == pager.getCurrentItem())
                tab.setTextColor(selectedTabTextColor);
            else//from   w  ww  . j  a va 2  s.  co  m
                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 source file:com.icoder.couldnewsclient.widget.PagerSlidingTabStrip.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);
            if (tab == selectedTabText)
                tab.setTextColor(tabTextSelectedColor);
            else/*from   ww w  .  jav  a2  s  . c om*/
                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));
                }
            }
        }
    }

    invalidate();
}

From source file:com.huoqiu.widget.pagertabstrip.PagerSlidingTabStrip.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);
            if (i == 0) {
                tab.setTextColor(Color.parseColor("#12c1c4"));
            } else {
                tab.setTextColor(Color.parseColor("#333333"));
            }//  ww w.j  a  va2s  . 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.android.yijiang.kzx.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);/* ww  w. j a va 2s.  co m*/
        } else {
            v.setPadding(tabPadding, 12, tabPadding, 0);
        }

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            //            tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize);
            //            tab.setTextSize(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 source file:com.ashish.routofy.PagerSlidingTabStrip.java

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

        if (tab_title != null) {
            tab_title.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) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }//  w  w  w .ja  v a 2  s  .co m
            }
        }
    }
}

From source file:com.example.moses.mosesnews.utils.PagerSlidingTabStrip.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);
            if (i == 0) {
                tab.setTextColor(getResources().getColor(android.R.color.holo_green_dark));
            } else {
                tab.setTextColor(tabTextColor);
            }/*  www.j  a  va  2s  .  c  om*/

            // 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.common.view.tab.PagerSlidingTabStrip.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);
            if (i == currentPosition) {
                tab.setTextColor(tabScrollTextColor);
            } else {
                tab.setTextColor(tabTextColor);
            }/*  www  .j  a  v a  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));
                }
            }
        }
    }

}