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.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/**
 * Will set text color of a TextView.//from  www. j a  va2s.c  om
 * 
 * @param viewId
 *            The view id.
 * @param textColor
 *            The text color (not a resource id).
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setTextColor(int viewId, int textColor) {
    TextView view = retrieveView(viewId);
    view.setTextColor(textColor);
    return this;
}

From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/**
 * Will set text color of a TextView.//from  w  w  w  .j  av a2 s. c o  m
 * 
 * @param viewId
 *            The view id.
 * @param textColorRes
 *            The text color resource id.
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setTextColorRes(int viewId, int textColorRes) {
    TextView view = retrieveView(viewId);
    view.setTextColor(context.getResources().getColor(textColorRes));
    return this;
}

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

private void checkBackground(int position) {
    for (int i = 0; i < tabCount; i++) {
        View vs = tabsContainer.getChildAt(i);
        vs.setBackgroundDrawable(getResources().getDrawable(android.R.color.transparent));
        if (vs instanceof TextView) {
            TextView tab = (TextView) vs;
            tab.setTextColor(getResources().getColor(android.R.color.black));
        }// ww w  . j  a  v  a  2 s  .  c  om
    }
    View vs = tabsContainer.getChildAt(position);
    vs.setBackgroundDrawable(tabBackgroundDrawable);
    if (vs instanceof TextView) {
        TextView tab = (TextView) vs;
        tab.setTextColor(tabchecktextcolor);
    }
}

From source file:com.ab.view.sliding.AbSlidingTabView2.java

/**
 * /*from  w  ww .  j  ava 2s  .  co  m*/
 * ???
 * @param index
 * @throws 
 */
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);

    if (D)
        Log.d(TAG, "old--startX:" + startX);
    //????????tab
    if (D)
        Log.d(TAG, "view" + index + ":" + tabView.getMeasuredWidth());
    if (D)
        Log.d(TAG, "ScrollView:" + mTabScrollView.getWidth());
    if (D)
        Log.d(TAG, "scrollX:" + scrollX);
    if (D)
        Log.d(TAG, "tabView right:" + tabView.getRight());
    if (D)
        Log.d(TAG, "tabView left:" + tabView.getLeft());

    if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) {
        if (D)
            Log.d(TAG, "??");
        int offsetX = 0;
        //??
        if (index == mTabLayout.getChildCount() - 1) {
            offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX;
            mTabScrollView.smoothScrollBy(offsetX, 0);
            scrollX = scrollX + offsetX;
            if (D)
                Log.d(TAG, "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;
            if (D)
                Log.d(TAG, "startX:" + startX + ",offsetX:" + offsetX);
            int toX = tabView.getLeft() - scrollX;
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }

    } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) {
        if (D)
            Log.d(TAG, "?");
        //?  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;
            if (D)
                Log.d(TAG, "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.manning.androidhacks.hack017.CreateAccountAdapter.java

private TextView createTitle(String text) {
    TextView ret = new TextView(mContext);
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    ret.setLayoutParams(params);/*from w  ww .j av  a 2 s  .  co  m*/
    ret.setTextSize(TypedValue.COMPLEX_UNIT_SP, 17);
    ret.setTextColor(Color.BLACK);
    ret.setText(text);

    return ret;
}

From source file:com.chalilayang.test.customview.springindicator.SpringIndicator.java

private void addTabItems() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
    tabs = new ArrayList<>();
    for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
        TextView textView = new TextView(getContext());
        if (viewPager.getAdapter().getPageTitle(i) != null) {
            textView.setText(viewPager.getAdapter().getPageTitle(i));
        }//from  w w  w .  j  a v  a  2 s . c  o  m
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(getResources().getColor(textColorId));
        if (textBgResId != 0) {
            textView.setBackgroundResource(textBgResId);
        }
        textView.setLayoutParams(layoutParams);
        final int position = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tabClickListener == null || tabClickListener.onTabClick(position)) {
                    viewPager.setCurrentItem(position);
                }
            }
        });
        tabs.add(textView);
        tabContainer.addView(textView);
    }
}

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

@Override
protected boolean onTap(final int index) {
    Log.v(TAG, "onTap");

    if (isPinch) {
        return false;
    }/*  ww w .  j  av a2 s  . c  o m*/

    aa = MainScreenActivity.annotations.get(index);

    if (aa == null) {
        return false;
    }

    try {
        aa.subtitle = aa.availabilityDescriptionShowingPrice(MainScreenActivity.showPrice);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    GeoPoint geoPoint = aa.mid;

    LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    popupView = vi.inflate(R.layout.dialog, null);

    TextView title = (TextView) popupView.findViewById(R.id.detailTitle);
    TextView subtitle = (TextView) popupView.findViewById(R.id.detailSubtitle);
    title.setTextColor(0xFFffffff);
    subtitle.setTextColor(0xFFcccccc);

    // set bubble title
    title.setText(aa.title != null ? aa.title : mContext.getString(R.string.unknown));

    // Bubble Flurry!
    Map<String, String> details = new HashMap<String, String>();
    details.put("Details for", aa.title);
    FlurryAgent.logEvent("Show_Details", details);

    // set bubble subtitle
    if (aa.subtitle == null) {
        subtitle.setText(R.string.full);
        aa.subtitle = mContext.getString(R.string.full);
    } else {
        if (aa.onStreet) {
            subtitle.setText(aa.subtitle);
        } else {
            if (aa.subtitle.startsWith("Estimated 0 of") || aa.subtitle.startsWith("Estimated -")
                    || aa.subtitle.startsWith("-")) {
                subtitle.setText(R.string.full);
                aa.subtitle = mContext.getString(R.string.full);
            } else {
                subtitle.setText(aa.subtitle);
            }
        }
    }

    LayoutParams mapDialogParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, geoPoint, 0, -20, LayoutParams.CENTER);
    MainScreenActivity.mapView.addView(popupView, mapDialogParams);

    popupView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.v(TAG, "Details tapped");

            // Bubble Flurry!
            Map<String, String> moreDetails = new HashMap<String, String>();
            moreDetails.put("Details for", aa.title);
            FlurryAgent.logEvent("Show_More_Details", moreDetails);

            DetailViewActivity.present(mContext, aa);
            return;
        }
    });

    //PreDraw creates infinite loop situations
    ViewTreeObserver vto = popupView.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Log.v(TAG, "onGlobalLayout");

            if ((aa == null) || (MainScreenActivity.mapView == null) || (MainScreenActivity.mc == null)
                    || (popupView == null)) {
                return;
            }

            // compromise until figure out horiz Point
            // offset(dx, 0) projection toPixels fromPixels
            // dip - pixels - lon getMeasuredWidth etc
            if ((popupView.getLeft() < MainScreenActivity.mapView.getLeft())
                    || (popupView.getRight() > MainScreenActivity.mapView.getRight())) {
                // assumes aa is set!
                MainScreenActivity.mc.animateTo(aa.mid);
            }

            // Separated for clarity - something missing re
            // -20 at top and view height at bottom...

            if ((popupView.getTop() < MainScreenActivity.mapView.getTop())
                    || (popupView.getBottom() > MainScreenActivity.mapView.getBottom())) {
                // assumes aa is set!
                MainScreenActivity.mc.animateTo(aa.mid);
            }

            // make sure only called one time!
            popupView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }
    });

    return true;
}

From source file:com.example.drugsformarinemammals.Combined_Search.java

private void displayMessage(String messageTitle, String message) {
    AlertDialog.Builder myalert = new AlertDialog.Builder(this);

    TextView title = new TextView(this);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setTextSize(20);/*from w w  w  . j a v  a 2 s  .  co  m*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText(messageTitle);
    title.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout layout = new LinearLayout(this);
    TextView text = new TextView(this);
    text.setTypeface(Typeface.SANS_SERIF);
    text.setTextSize(20);
    text.setPadding(10, 10, 10, 10);
    text.setText(message);
    layout.addView(text);

    myalert.setView(layout);
    myalert.setCustomTitle(title);
    myalert.setCancelable(true);
    myalert.show();

}

From source file:com.aniruddhc.acemusic.player.MainActivity.MainActivity.java

/**
 * Inflates the generic MainActivity ActionBar layout.
 *
 * @param inflater The ActionBar's menu inflater.
 * @param menu The ActionBar menu to work with.
 *///from ww  w. j  a  v a 2 s.  c  om
private void showMainActivityActionItems(MenuInflater inflater, Menu menu) {
    //Inflate the menu.
    getMenu().clear();
    inflater = getMenuInflater();
    inflater.inflate(R.menu.main_activity, menu);

    //Set the ActionBar background
    getActionBar().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
    getActionBar().setDisplayShowTitleEnabled(true);
    getActionBar().setDisplayUseLogoEnabled(false);
    getActionBar().setHomeButtonEnabled(true);

    //Set the ActionBar text color.
    int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    if (actionBarTitleId > 0) {
        TextView title = (TextView) findViewById(actionBarTitleId);
        if (title != null) {
            title.setTextColor(0xFFFFFFFF);
        }

    }

}

From source file:com.asc_ii.bangnote.bigbang.BigBangLayout.java

public void addTextItem(String text) {
    TextView view = new TextView(getContext());
    view.setText(text);/*from w ww .  j  a  va  2 s.co m*/
    view.setBackgroundResource(R.drawable.item_background);
    view.setTextColor(ContextCompat.getColorStateList(getContext(), R.color.bigbang_item_text));
    view.setGravity(Gravity.CENTER);
    if (mItemTextSize > 0)
        view.setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemTextSize);
    addView(view);
}