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.astuetz.PagerSlidingTabStripPlus.java

private void updateTabStyles() {

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

        for (int k = 0; k < ((LinearLayout) tabsContainer.getChildAt(i)).getChildCount(); k++) {

            View v = ((LinearLayout) tabsContainer.getChildAt(i)).getChildAt(k);

            v.setBackgroundResource(tabBackgroundResId);

            if (v instanceof TextView) {

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

                // Setting color of textView
                if (textColorTab != null) {
                    tab.setTextColor(textColorTab);
                } else {
                    tab.setTextColor(Color.BLACK);
                }//from   w  w  w .  jav  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));
                    }
                }
            }
        }
    }
}

From source file:base.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        //            v.setBackgroundResource(tabBackgroundResId);
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/*from   w  w w.jav  a 2 s . 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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.gc.materialdesign.views.PagerSlidingTabStrip.java

public void updateTabStyles(int position) {
    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 == position) {
                //  tab.setBackgroundResource(R.drawable.selected_tab_bg);
                tab.setTextColor(tabSelectedTextColor);
                tab.setBackgroundColor(tabSelectedBgColor);
            } else {
                //  tab.setBackgroundColor(getResources().getColor(android.R.color.transparent));
                tab.setTextColor(tabTextColor);
                tab.setBackgroundColor(tabBgColor);
            }//  ww  w .  j  a  va2  s.co  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.ghkjgod.lightnovel.component.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.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/*from  www . j  a  v a 2 s  .co  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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.microsoft.office365.msgraphsnippetapp.SnippetDetailFragment.java

private void clipboard(TextView tv) {
    // which view are we copying to the clipboard?
    int which;// w  ww .  j a v a 2s.c  o  m

    switch (tv.getId()) {
    case txt_request_url: // the url field
        which = req_url;
        break;

    case txt_response_headers: // the display headers
        which = response_headers;
        break;

    case txt_response_body: // the response body
        which = response_body;
        break;

    default:
        which = UNSET; // don't assign a prefix
    }

    // if we know which view we're copying, prefix it with useful info
    String what = which == UNSET ? "" : getString(which) + " ";

    // concat the clipboard data to this String
    what += getString(clippy);

    // inform the user that data was added to the clipboard
    Toast.makeText(getActivity(), what, Toast.LENGTH_SHORT).show();

    // depending on our API, do it one way or another...
    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.dsdar.thosearoundme.util.MemberAddContactsListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Gets the Cursor object currently bound to the ListView
    final Cursor cursor = mAdapter.getCursor();
    Contact aContactToBeRemoved = null;/*ww w  .  j  ava 2  s  .co m*/
    String aContactCursorId;
    String aEmailId = null;
    String aPhoneNumber = null;
    boolean isExist = false;
    // Moves to the Cursor row corresponding to the ListView item that was
    // clicked
    cursor.moveToPosition(position);

    // Creates a contact lookup Uri from contact ID and lookup_key
    final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    // Notifies the parent activity that the user selected a contact. In a
    // two-pane layout, the
    // parent activity loads a ContactDetailFragment that displays the
    // details for the selected
    // contact. In a single-pane layout, the parent activity starts a new
    // activity that
    // displays contact details in its own Fragment.
    // niaz checking
    Log.d("positionI", String.valueOf(position));
    CheckedTextView aCheckedTV = (CheckedTextView) v.findViewById(android.R.id.text1);
    mOnContactSelectedListener.onContactSelected(uri);
    HashMap<Integer, Boolean> aHashMap = new HashMap<Integer, Boolean>();
    aHashMap.put(position, true);
    final Uri aContactUri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    String aName = cursor.getString(ContactsQuery.DISPLAY_NAME);

    TextView textName = (TextView) v.findViewById(R.id.phone);

    if (textName.getText() != null) {
        Log.d("FINAL", textName.getText().toString());
        aPhoneNumber = textName.getText().toString();
        // Toast.makeText(itsContext, "Contact Addded Successfully !",
        // Toast.LENGTH_LONG).show();

        // Cursor aContactCursor = itsContext.getContentResolver().query(
        // aContactUri, null, null, null, null);
        // if (aContactCursor.moveToFirst()) {
        // int idx = cursor.getColumnIndex(ContactsContract.Contacts._ID);
        // aContactCursorId = cursor.getString(idx);
        // int aNameIdx = aContactCursor
        // .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER);
        // //
        // // aEmailId = cursor.getString(ContactsQuery.LOOKUP_KEY);
        // // aPhoneNumber = cursor.getString(ContactsQuery.ID);
        // // Commented by Niaz for Multiple phone number
        // }

        JSONObject aContactJSONObject;

        // Notifies the parent activity that the user selected a contact. In
        // a two-pane layout, the
        // parent activity loads a ContactDetailFragment that displays the
        // details for the selected
        // contact. In a single-pane layout, the parent activity starts a
        // new activity that
        // displays contact details in its own Fragment.
        // aEmailId = "qwe";
        // aPhoneNumber = "1234";

        if (checkedTvStates.contains(aHashMap)) {
            checkedTvStates.remove(aHashMap);
            aContactToBeRemoved = new Contact();
            aContactToBeRemoved.setEmail(aEmailId);
            aContactToBeRemoved.setName(aName);
            aContactToBeRemoved.setPhoneNumber(aPhoneNumber);
            aCheckedTV.setChecked(false);
        } else {
            checkedTvStates.add(aHashMap);
            aCheckedTV.setChecked(true);
            Contact aContact = new Contact();
            aContact.setName(aName);
            aContact.setEmail(aEmailId);
            aContact.setPhoneNumber(aPhoneNumber);

            itsContactsList.add(aContact);
        }

        if (aContactToBeRemoved != null) {
            itsContactsList.remove(aContactToBeRemoved);
        }
        // aCheckBox.setButtonDrawable(R.drawable.checkbox_notify);

        try {
            aContactJSONObject = new JSONObject();
            aMembersArray = new JSONArray();
            for (int index = 0; index < itsContactsList.size(); index++) {
                aContactJSONObject = new JSONObject();

                aContactJSONObject.put("emailId", itsContactsList.get(index).getEmail());
                aContactJSONObject.put("phone", itsContactsList.get(index).getPhoneNumber());
                aContactJSONObject.put("name", itsContactsList.get(index).getName());
                aMembersArray.put(aContactJSONObject);

            }
        } catch (JSONException e) {

            Log.e("JsonException", "Json Exception occured ", e);
        } catch (Exception e) {

            Log.e("Exception", "Exception occured ", e);
        }

        // If two-pane layout sets the selected item to checked so it
        // remains
        // highlighted. In a
        // single-pane layout a new activity is started so this is not
        // needed.
        if (mIsTwoPaneLayout) {
            getListView().setItemChecked(position, true);
        }
    } else {
        Toast.makeText(itsContext, "Contact Not Addded! The Contact you selected does not have a Phone Number",
                Toast.LENGTH_LONG).show();
    }
}

From source file:com.bwash.bwashcar.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        if (pager.getAdapter() instanceof IconTabProvider) {
            TextView tab = (TextView) v.findViewById(R.id.text);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(((IconTabProvider) pager.getAdapter()).getPageTextColor(i));
            tab.setCompoundDrawablesWithIntrinsicBounds(
                    getResources().getDrawable(((IconTabProvider) pager.getAdapter()).getPageIconResId(i)),
                    null, null, null);/*w ww.  j  a va  2  s  . c o m*/
            //            tab.setBackgroundDrawable(getResources().getDrawable(((IconTabProvider)pager.getAdapter()).getPageIconResId(i)));
            // 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));
                }
            }
        } else {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(0xffffffff);
            // 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.freud.mrzz.views.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.tv_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }//from  ww  w  . jav  a2  s .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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.google.sample.cast.refplayer.Synchronization.java

public void clickLink(View view) {
    TextView indexView = (TextView) view.findViewById(R.id.index);
    Log.d(TAG, "clickLink: " + indexView.getText().toString());
    String part[] = indexView.getText().toString().split("-", 2);
    String index = part[0];//w ww .jav  a 2s.c  om
    String identity = part[1];
    if (identity.charAt(0) != '0' && !(condition == 1 && Role == 1))
        setVibrate(100);
    VideoTime = getVideoTime();
    sendMessage("R&&" + VideoTime + "&&" + UserIndex + "&&" + index);
}

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

private void setTextViewStyle(View v) {
    TextView tab = (TextView) v;
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab.setTypeface(tabTypeface, tabTypefaceStyle);
    // TODO/*  ww  w.  ja  v  a  2s.c om*/
    //tab.setTextColor(tabTextColor);
    ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, //1
            new int[] { android.R.attr.state_selected }, //2
            new int[] {} //3
    }, new int[] { Color.WHITE, //1
            Color.WHITE, //2
            getResources().getColor(R.color.tab_text_color_unselected) //3
    });
    tab.setTextColor(colorStateList);
    tab.setTextScaleX(tabTextScaleX);

    // 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));
        }
    }
}