Example usage for android.widget TextView setTextColor

List of usage examples for android.widget TextView setTextColor

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setTextColor(ColorStateList colors) 

Source Link

Document

Sets the text color.

Usage

From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);// ww  w .ja v a2 s  .  c  om
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextSize(getResources().getDimension(R.dimen.pager_tab_strip_slider_textsize));
    tab.setTextColor(getResources().getColor(R.color.pager_tab_strip_text_color));

    addTab(position, tab);
}

From source file:com.chj.indicator.lib.TabSlidingIndicator.java

/**
 * ?//from   ww  w.j  a va2  s .c  o  m
 */
private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        // TODO:
        if (v instanceof TextView) {

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

            if (this.pager.getCurrentItem() == i) {
                // 
                tab.setTextColor(tabSelectedTextColor);
            } else {
                // 
                tab.setTextColor(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));
                }
            }
        }
    }

}

From source file:com.bob.googleplay.view.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);
            tab.setTextColor(tabTextColor);

            // ################??###################
            // ?item,??
            if (pager.getCurrentItem() == i) {
                // 
                tab.setTextColor(tabSelectedTextColor);
            } else {
                // 
                tab.setTextColor(tabNormalTextColor);
            }/*w  ww. ja  va  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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

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));
                }/*www .  j ava 2  s  .com*/
            }
        }
    }

}

From source file:com.android.nsboc.ComposeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mItem != null) {
        switch (mItem.id + "") {
        case "1":
            mRootView = inflater.inflate(R.layout.form_unlicensed, container, false);
            break;
        case "2":
            mRootView = inflater.inflate(R.layout.form_salon, container, false);
            break;
        }/*from w  ww.  j a va  2 s .c  o m*/
    }

    showCurrentDateInEditText();

    ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle);
    if (complianceToggle != null) {
        final LinearLayout complianceContainer = (LinearLayout) mRootView
                .findViewById(R.id.compliance_container);

        complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (!isChecked) {
                    complianceContainer.setVisibility(View.VISIBLE);

                    final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(),
                            R.layout.compliance_layout, null);

                    Spinner violationTypeSpinner = (Spinner) complianceLayout
                            .findViewById(R.id.violation_type_spinner);
                    violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                            switch (position) {
                            case 0:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.VISIBLE);
                                break;
                            case 1:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.GONE);
                                break;
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                        }
                    });

                    ToggleButton anotherToggle = (ToggleButton) complianceLayout
                            .findViewById(R.id.compliance_toggle);
                    anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout));

                    complianceContainer.addView(complianceLayout);
                } else {
                    complianceContainer.setVisibility(View.GONE);
                }
            }
        });
    }

    ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle);
    if (emailToggle != null) {
        final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout);

        emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    emailLayout.setVisibility(View.VISIBLE);
                } else {
                    emailLayout.setVisibility(View.GONE);
                }
            }
        });
    }

    final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview);
    if (noticeTextView != null) {
        noticeTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (noticeTextView.getCurrentTextColor() == Color.BLACK) {
                    noticeTextView.setText(R.string.civil_citation_header);
                    noticeTextView.setTextColor(Color.parseColor("#17405e"));
                    noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>"));
                    mRootView.findViewById(R.id.civil_citation).requestFocus();
                } else {
                    noticeTextView.setText(R.string.civil_citation_notice);
                    noticeTextView.setMaxLines(Integer.MAX_VALUE);
                    noticeTextView.setTextColor(Color.BLACK);
                    noticeTextView.setText(
                            noticeTextView.getText().toString().replace("<u>", "").replace("</u>", ""));
                }
            }
        });
    }

    Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state);
    if (stateSpinner != null) {
        stateSpinner.setSelection(27);
    }

    return mRootView;
}

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

private void updateTabStyles(boolean isSelected, View v) {
    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);

        // 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);//from w  w w . j a  va2  s  . c om
            } else {
                tab.setText(tab.getText().toString().toUpperCase(locale));
            }
        }
        if (isSelected) {
            tab.setTextColor(selectedTabTextColor);
        }
    }
}

From source file:com.carinsurance.pagerslidingtabstrip.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);
            tab.setTextColor(tabTextColor);
            // tab.setTextColor(Color.parseColor("#00a2d0"));

            // 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   ww w.ja v a2s.c  o m
            }
        }
    }

}

From source file:cn.qiuc.org.igoogleplay.lib.pagerslidingtab.PagerSlidingTab.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 v a 2s . c  om*/
        } else {
            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);
            tab.setTextColor(
                    i == 0 ? getResources().getColor(R.color.slidingtab_indicatorcolor) : 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:org.anhonesteffort.flock.SubscriptionStripeFragment.java

private void handleSetupFormForEditingCard() {
    TextView statusView = (TextView) subscriptionActivity.findViewById(R.id.card_subscription_status);
    statusView.setVisibility(View.VISIBLE);

    if (AccountStore.getLastChargeFailed(subscriptionActivity)) {
        statusView.setText(R.string.payment_failed);
        statusView.setTextColor(getResources().getColor(R.color.error_red));
    } else {/*from   w  w  w .  j av  a2s.c o m*/
        statusView.setText(R.string.subscription_is_active);
        statusView.setTextColor(getResources().getColor(R.color.success_green));
    }

    EditText cardNumberView = (EditText) subscriptionActivity.findViewById(R.id.card_number);
    EditText cardExpirationView = (EditText) subscriptionActivity.findViewById(R.id.card_expiration);

    if (cardInformation.isPresent()) {
        if (StringUtils.isEmpty(cardNumberView.getText().toString()))
            cardNumberView.setText("**** **** **** " + cardInformation.get().getCardLastFour());

        if (StringUtils.isEmpty(cardExpirationView.getText().toString()))
            cardExpirationView.setText(cardInformation.get().getCardExpiration());
    }

    Button buttonCancel = (Button) subscriptionActivity.findViewById(R.id.button_card_cancel);
    Button buttonStartSubscription = (Button) subscriptionActivity.findViewById(R.id.button_card_action);

    buttonCancel.setVisibility(View.VISIBLE);
    buttonCancel.setText(R.string.cancel_subscription);
    buttonCancel.setBackgroundColor(getResources().getColor(R.color.error_red));
    buttonCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            handlePromptCancelSubscription();
        }
    });

    buttonStartSubscription.setText(R.string.save_card);
    buttonStartSubscription.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            handleVerifyCardAndPutToServer();
        }
    });

    initCardNumberHelper();
    initCardExpirationHelper();
}

From source file:com.ccj.tabpager.view.ZDMSlidingTab.java

private 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.setTextColor(selectedTextColor);
            } else {
                tab.setTextColor(tabTextColor);
            }/*from w ww  . 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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}