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.edu.qzu.face.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(tabTextColorStateList);

            // 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.j  av a2s  . c o  m
            }
        }
    }

}

From source file:android.support.designox.widget.Snackbar.java

/**
 * Sets the text color of the action specified in
 * {@link #setAction(CharSequence, View.OnClickListener)}.
 *///w  ww .  ja  v  a2  s. c  om
@NonNull
public Snackbar setActionTextColor(ColorStateList colors) {
    final TextView tv = mView.getActionView();
    tv.setTextColor(colors);
    return this;
}

From source file:android.support.designox.widget.Snackbar.java

/**
 * Sets the text color of the action specified in
 * {@link #setAction(CharSequence, View.OnClickListener)}.
 *///w w  w. jav  a2 s . com
@NonNull
public Snackbar setActionTextColor(@ColorInt int color) {
    final TextView tv = mView.getActionView();
    tv.setTextColor(color);
    return this;
}

From source file:cn.com.zzwfang.view.indicator.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);//  w ww. j  a v a2s.  c o  m
        } 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);

            if (pager.getCurrentItem() == i) {
                tab.setTextColor(tabTextColor);
            } else {
                tab.setTextColor(tabUnselectedTextColor);
            }

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                tab.setText(tab.getText().toString().toUpperCase(locale));
            }
        }
    }

}

From source file:com.amaze.filemanager.fragments.ProcessViewer.java

public void processExtractResults(DataPackage dataPackage) {
    if (!running)
        return;//www .  j a  va  2  s  .  c  om
    if (getResources() == null)
        return;
    final int id = dataPackage.getId();

    if (!CancelledExtractIds.contains(id)) {
        if (ExtractIds.contains(id)) {

            boolean completed = dataPackage.isCompleted();
            View process = rootView.findViewWithTag("extract" + id);
            if (completed) {
                rootView.removeViewInLayout(process);
                ExtractIds.remove(ExtractIds.indexOf(id));
            } else {
                String name = dataPackage.getName();
                int p1 = dataPackage.getP1();
                long p3 = dataPackage.getTotal();
                long p2 = dataPackage.getDone();
                ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1);
                if (p1 <= 100) {
                    ((TextView) process.findViewById(R.id.progressText)).setText(
                            utils.getString(getActivity(), R.string.extracting) + "\n" + name + "\n" + p1 + "%"
                                    + "\n" + utils.readableFileSize(p2) + "/" + utils.readableFileSize(p3));

                    p.setProgress(p1);
                }
            }
        } else {
            CardView root = (CardView) getActivity().getLayoutInflater().inflate(R.layout.processrow, null);
            root.setTag("extract" + id);

            ImageView progressImage = ((ImageView) root.findViewById(R.id.progressImage));
            ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button);
            TextView progressText = (TextView) root.findViewById(R.id.progressText);

            if (mainActivity.theme1 == 1) {

                root.setCardBackgroundColor(R.color.cardView_foreground);
                root.setCardElevation(0f);
                cancel.setImageResource(R.drawable.ic_action_cancel);
                progressText.setTextColor(Color.WHITE);
                progressImage.setImageResource(R.drawable.ic_doc_compressed);
            } else {

                // cancel has default src set for light theme
                progressText.setTextColor(Color.BLACK);
                progressImage.setImageResource(R.drawable.ic_doc_compressed_black);
            }

            cancel.setOnClickListener(new View.OnClickListener() {

                public void onClick(View p1) {
                    Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping),
                            Toast.LENGTH_LONG).show();
                    Intent i = new Intent("excancel");
                    i.putExtra("id", id);
                    getActivity().sendBroadcast(i);
                    rootView.removeView(rootView.findViewWithTag("extract" + id));

                    ExtractIds.remove(ExtractIds.indexOf(id));
                    CancelledExtractIds.add(id);
                    // TODO: Implement this method
                }
            });

            String name = dataPackage.getName();
            int p1 = dataPackage.getP1();

            ((TextView) root.findViewById(R.id.progressText))
                    .setText(utils.getString(getActivity(), R.string.extracting) + "\n" + name);
            ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1);
            p.setProgress(p1);
            ExtractIds.add(id);
            rootView.addView(root);
        }
    }
}

From source file:com.app.viaje.viaje.MapsActivity.java

/**
 * @description function that creates//  ww  w . j ava  2  s  . c  o m
 * a new post record to firebase.
 * @param text
 */
private void sendThePostToFirebase(final String text) {

    //Get timestamp
    final long millis = new Date().getTime();

    //Shared Preference of Motorist.
    SharedPreferences sharedPreferences = getSharedPreferences("motoristInfo", Context.MODE_PRIVATE);
    String email_address = sharedPreferences.getString("email", "");

    //Shared Preference for User Coordinates.
    SharedPreferences userCoordinates = getSharedPreferences("userCoordinates", Context.MODE_PRIVATE);
    final double latitude = Double.parseDouble(userCoordinates.getString("latitude", ""));
    final double longitude = Double.parseDouble(userCoordinates.getString("longitude", ""));

    Query queryRef = dbRef.child(ViajeConstants.USERS_KEY).orderByChild(ViajeConstants.EMAIL_ADDRESS_FIELD)
            .equalTo(email_address);

    queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            for (DataSnapshot motoristSnapshot : dataSnapshot.getChildren()) {

                //Get single motorist and pass it to online user.
                Motorist motorist = motoristSnapshot.getValue(Motorist.class);

                /**
                 * Create Post instance
                 * to save to "posts"
                 * at firebase.
                 */
                Post post = new Post();

                post.setLat(latitude);
                post.setLng(longitude);
                post.setText(text);
                post.setTimestamp(millis);
                post.setUser(motorist);

                dbRef.child(ViajeConstants.POSTS_KEY).push().setValue(post);

                Snackbar snackbar = Snackbar.make(relativeLayout, "Thanks for the concern..",
                        Snackbar.LENGTH_LONG);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.app_color));
                snackbar.show();
            }

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

            Log.w("ERROR: ", "loadPost:onCancelled", databaseError.toException());
        }
    });

}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

public void showNoInternetScreen() {
    showLoadingScreen();/*from   w  w  w.  java 2s.co m*/
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setVisibility(View.INVISIBLE);
    TextView noConnectionTV = (TextView) findViewById(R.id.loading_tv);
    noConnectionTV.setText("NO INTERNET CAN'T DOWNLOAD DATA FOR THE FIRST TIME :(");
    noConnectionTV.setTextColor(Color.GRAY);
    noConnectionTV.setPadding(40, 30, 40, 0);
}

From source file:com.co.iatech.crm.sugarmovil.activities.ui.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//w  w w .  j  a  va  2 s. com
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setTextColor(Color.WHITE);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    Log.d("TABS", " Crea default TabView");
    return textView;
}

From source file:com.axolotl.yanews.customize.SlidingTabLayout.java

/**
 * tabview. tab view/*from   w w w.ja  v a 2 s  .  co  m*/
 * {@link #setCustomTabView(int, int)}.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context, null, 0);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTab_text_size_sp);
    if (mBold) {
        textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    } else {
        textView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
    }
    if (mChangeTextColor) {
        textView.setTextColor(mNormalColor);
    }
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (mBackgroundResource != 0) {
        textView.setBackgroundResource(mBackgroundResource);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // If we're running on Honeycomb or newer, then we can use the Theme's
            // selectableItemBackground to ensure that the View has a pressed state
            TypedValue outValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
            textView.setBackgroundResource(outValue.resourceId);
        }
    }

    //wtf
    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    //            // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
    //            textView.setAllCaps(true);
    //        }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, 0, padding, 0);
    return textView;
}

From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            //                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabNormalTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }//ww w  .  j  a  v  a 2  s .  co m
            }
        }
    }
}