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:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java

/**
 * ???./*from   w  ww.j  ava  2  s. c  om*/
 *
 * @param index the index
 */
public void computeTabImg(int index) {

    for (int i = 0; i < tabItemList.size(); i++) {
        TextView tv = tabItemList.get(i);
        tv.setTextColor(tabColor);
        tv.setSelected(false);
        if (index == i) {
            tv.setTextColor(tabSelectColor);
            tv.setSelected(true);
        }
    }

    //
    final View tabView = mTabLayout.getChildAt(index);
    AbViewUtil.measureView(tabView);

    LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight);
    mParams.topMargin = -tabSlidingHeight;
    mTabImg.setLayoutParams(mParams);

    AbLogUtil.d(AbSlidingSmoothTabView.class, "old--startX:" + startX);
    //????????tab
    AbLogUtil.d(AbSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "scrollX:" + scrollX);
    AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView right:" + tabView.getRight());
    AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft());

    if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) {
        AbLogUtil.d(AbSlidingSmoothTabView.class, "??");
        int offsetX = 0;
        //??
        if (index == mTabLayout.getChildCount() - 1) {
            offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0);
            startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth();
        } else {
            offsetX = tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) {
        AbLogUtil.d(AbSlidingSmoothTabView.class, "?");
        //?  offsetX
        int offsetX = 0;
        if (index == 0) {
            offsetX = -scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            imageSlide(mTabImg, startX, 0, 0, 0);
            startX = 0;
        } else {
            offsetX = -tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            AbLogUtil.d(AbSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else {
        int toX = tabView.getLeft() - scrollX;
        imageSlide(mTabImg, startX, toX, 0, 0);
        startX = toX;
    }

    mSelectedTabIndex = index;
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * ???.//from  w w w  . j a  v a  2s .c o  m
 *
 * @param index the index
 */
public void computeTabImg(int index) {

    for (int i = 0; i < tabItemList.size(); i++) {
        TextView tv = tabItemList.get(i);
        tv.setTextColor(tabColor);
        tv.setSelected(false);
        if (index == i) {
            tv.setTextColor(tabSelectColor);
            tv.setSelected(true);
        }
    }

    //
    final View tabView = mTabLayout.getChildAt(index);
    ESViewUtil.measureView(tabView);

    LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight);
    mParams.topMargin = -tabSlidingHeight;
    mTabImg.setLayoutParams(mParams);

    ESLogUtil.d(ESSlidingSmoothTabView.class, "old--startX:" + startX);
    //????????tab
    ESLogUtil.d(ESSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "scrollX:" + scrollX);
    ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView right:" + tabView.getRight());
    ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft());

    if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) {
        ESLogUtil.d(ESSlidingSmoothTabView.class, "??");
        int offsetX = 0;
        //??
        if (index == mTabLayout.getChildCount() - 1) {
            offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0);
            startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth();
        } else {
            offsetX = tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) {
        ESLogUtil.d(ESSlidingSmoothTabView.class, "?");
        //?  offsetX
        int offsetX = 0;
        if (index == 0) {
            offsetX = -scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            imageSlide(mTabImg, startX, 0, 0, 0);
            startX = 0;
        } else {
            offsetX = -tabView.getMeasuredWidth();
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            ESLogUtil.d(ESSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else {
        int toX = tabView.getLeft() - scrollX;
        imageSlide(mTabImg, startX, toX, 0, 0);
        startX = toX;
    }

    mSelectedTabIndex = index;
}

From source file:com.arconus.dicecommander.ui.dialogs.PowerRollResultDialog.java

private void showCritStatus(View view) {
    if (roll != null) {
        CriticalStatus status = roll.getCritStatus();

        if (status == CriticalStatus.SUCCESS || status == CriticalStatus.FAILURE) {
            TextView critStatus = (TextView) view.findViewById(R.id.critical_status);
            if (critStatus != null) {
                critStatus.setVisibility(View.VISIBLE);

                int stringID = (status == CriticalStatus.SUCCESS) ? R.string.critical_hit
                        : R.string.critical_failure;
                int colorID = (status == CriticalStatus.SUCCESS) ? R.color.critical_hit
                        : R.color.critical_failure;

                critStatus.setText(stringID);
                critStatus.setTextColor(getResources().getColor(colorID));
            }/*  w ww . j ava 2s  .  co  m*/
        }
    }
}

From source file:com.chenl.widgets.flippablestackview.indicator.OrientedPagerSlidingTabLayout.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View childView = tabsContainer.getChildAt(i);
        if (tabBackgroundResId == -1) {
            childView.setBackgroundDrawable(mTabBackgroundRes);
        } else {/*from   w w  w .  j  a v a  2 s .  c o m*/
            childView.setBackgroundResource(tabBackgroundResId);
        }
        if (childView instanceof TextView) {
            TextView tab = (TextView) childView;
            tab.setTextSize(tabTextSize);
            tab.setTextColor(tabTextColor);
            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.purenexussettings.utils.SlidingTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = createDefaultTabView(getContext());
        TextView tabTitleView = (TextView) tabView;

        // not completely sure what changes result from this...
        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;// ww w  . j a  v a 2 s. c  o m
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTextColor(Color.WHITE);
        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);
        }
    }
}

From source file:cn.wander.Utils.views.pageindicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    RelativeLayout tablayout = (RelativeLayout) View.inflate(getContext(), R.layout.tab_item_layout, null);

    final TextView tabView = (TextView) tablayout.findViewById(R.id.tab_item_title);
    tabView.setTag(index);//from  ww  w .j a v  a2 s  .c o  m
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 19);
    tabView.setText(text);
    tabView.setTextColor(getResources().getColor(R.color.kw_common_cl_white));
    if (iconResId != 0) {
        //             tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
        ImageView iconView = (ImageView) tablayout.findViewById(R.id.tab_item_icon);
        iconView.setImageResource(iconResId);
        iconView.setVisibility(View.VISIBLE);
    }

    mTabLayout.addView(tablayout, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:com.adarshahd.indianrailinfo.donate.TrainEnquiry.java

private void startDetailsActivity() {

    //For testing!!!
    /*File file = new File("/sdcard/train_details_trn_number.html");
    String result = "";/*from  ww  w . j av a 2 s.  c  o  m*/
    try {
    FileInputStream stream = new FileInputStream(file);
    InputStreamReader readerStream = new InputStreamReader(stream);
    BufferedReader reader = new BufferedReader(readerStream);
    String str;
    while((str = reader.readLine()) != null) {
        result += str;
    }
    } catch (IOException e) {
    e.printStackTrace();
    }*/

    if (mPage.contains("unavailable")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText(
                "Response from server: \n\n\"The requested service is currently unavailable. Please try again later\"");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }
    if (mPage.contains("invalid")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText("Invalid Station code! Please select the station code from drop down list.");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }
    if (mPage.contains("No Matching Trains")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText("No Matching train found! Please check the train number/name");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }

    //put the required intent data and start TrainEnquiryDetails activity.
    Intent intent = new Intent(this, TrainEnquiryDetails.class);
    intent.putExtra(TRAIN, mTrainNumber);
    intent.putExtra(SEARCH, searchUsingTrnNumber);
    intent.putExtra(PAGE, mPage);
    intent.putExtra(SRC, mACTFrom.getText().toString());
    intent.putExtra(DST, mACTTo.getText().toString());
    intent.putExtra(DAY_TRAVEL, mCal.get(Calendar.DAY_OF_MONTH));
    intent.putExtra(MONTH_TRAVEL, mCal.get(Calendar.MONTH));
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    //Try to parse the mTrainNumber;
    try {
        Integer.parseInt(mTrainNumber);
        isInteger = true;
    } catch (Exception e) {
        isInteger = false;
    }
    intent.putExtra(ISINT, isInteger);
    startActivity(intent);
}

From source file:cn.ieclipse.af.view.PagerSlidingTabStrip.java

private void setCurrentTabTextColor(int position) {
    View v1 = tabsContainer.getChildAt(position);
    View v2 = tabsContainer.getChildAt(selectedPosition);
    if (v1 != null && v1 instanceof TextView) {
        TextView tab2 = (TextView) v2;
        tab2.setTextColor(getTextColor());
        TextView tab1 = (TextView) v1;/* w  w w .jav  a  2  s .co  m*/
        tab1.setTextColor(tabSelectTextColor);
    }
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentOverzicht.java

/**
 * Populate the koopman fragment item details item when the loader has finished
 * @param loader the cursor loader//from  w  ww  .  j av  a 2  s .  c om
 * @param data data object containing one or more koopman rows with joined sollicitatie data
 */
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {

        // get the markt id from the sharedprefs
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0);

        // koopman photo
        Glide.with(getContext())
                .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL)))
                .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage);

        // koopman naam
        String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " "
                + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM));
        mKoopmanVoorlettersAchternaamText.setText(naam);

        // koopman erkenningsnummer
        String erkenningsnummer = data
                .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER));
        mErkenningsnummerText.setText(erkenningsnummer);

        // koopman sollicitaties
        View view = getView();
        if (view != null) {
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder);
            placeholderLayout.removeAllViews();

            // add multiple markt sollicitatie views to the koopman items
            while (!data.isAfterLast()) {

                // inflate sollicitatie layout and populate its view items
                View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie,
                        null);

                // highlight the sollicitatie for the current markt
                if (data.getCount() > 1 && marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
                }

                // markt afkorting
                String marktAfkorting = data
                        .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING));
                TextView marktAfkortingText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_markt_afkorting);
                marktAfkortingText.setText(marktAfkorting);

                // koopman sollicitatienummer
                String sollicitatienummer = data.getString(
                        data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER));
                TextView sollicitatienummerText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_sollicitatie_nummer);
                sollicitatienummerText.setText(sollicitatienummer);

                // koopman sollicitatie status
                String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status"));
                TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status);
                sollicitatieStatusText.setText(sollicitatieStatus);
                if (sollicitatieStatus != null && !sollicitatieStatus.equals("?")
                        && !sollicitatieStatus.equals("")) {
                    sollicitatieStatusText
                            .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
                    sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(),
                            Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus)));
                }

                // add view and move cursor to next
                placeholderLayout.addView(childLayout, data.getPosition());
                data.moveToNext();
            }
        }
    }
}

From source file:gov.sfmta.sfpark.DetailViewActivity.java

public TextView normalText(String val) {
    TextView ntv = new TextView(this);
    ntv.setPadding(8, 7, 5, 7);/*from  w  w  w.  j a  v a  2s .c om*/
    ntv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    ntv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    ntv.setTextColor(Color.BLACK);
    ntv.setText(val);
    return ntv;
}