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.bhmedia.hnbus.slidingtab.SlidingTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*w w w .  ja v  a2 s. c  o m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate
            // it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        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);
        }
        tabTitleView.setTextColor(getResources().getColorStateList(R.layout.tab_selector));
        tabTitleView.setTextSize(14);
    }
}

From source file:com.sdspikes.fireworks.FireworksActivity.java

private TextView makeNewCardTextView(int width, GameState.Card card) {
    width = Math.min(width, MAX_CARD_WIDTH);
    width = Math.max(width, MIN_CARD_WIDTH);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT);
    TextView textView = new TextView(this);
    textView.setLayoutParams(params);//w w  w. j  a  v  a 2 s . co  m
    textView.setGravity(Gravity.CENTER);
    textView.setText(String.valueOf(card.rank));
    textView.setBackgroundResource(HandFragment.cardColorToBGColor.get(card.color));
    textView.setTextColor(getResources().getColor(HandFragment.cardColorToTextColor(card.color)));
    return textView;
}

From source file:com.speed.traquer.app.TraqComplaintTaxi.java

private void PromptCustomDialog() {

    // Create custom dialog object
    final Dialog dialog = new Dialog(TraqComplaintTaxi.this);
    // Include dialog.xml file
    dialog.setContentView(R.layout.activity_submit_social);
    // Set dialog title
    dialog.setTitle("Submit via");

    // set values for custom dialog components - text, image and button
    final TextView twitterText = (TextView) dialog.findViewById(R.id.textTwitterDialog);
    twitterText.setText("Twitter");

    final TextView facebookText = (TextView) dialog.findViewById(R.id.textFacebookDialog);
    facebookText.setText("Facebook");

    final TextView defaultText = (TextView) dialog.findViewById(R.id.textDefaultDialog);
    defaultText.setText("Default");
    defaultText.setTextColor(getResources().getColor(R.color.Orange));

    final TextView smsText = (TextView) dialog.findViewById(R.id.textSMSDialog);
    smsText.setText("SMS");

    final ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog);
    image.setImageResource(R.drawable.icon_twitter);

    final ImageView imageFb = (ImageView) dialog.findViewById(R.id.imageDialogFb);
    imageFb.setImageResource(R.drawable.ic_fb_grey);

    final ImageView imageDefault = (ImageView) dialog.findViewById(R.id.imageDialogDefault);
    imageDefault.setImageResource(R.drawable.icon_traquer_color);
    isDefaultSelected = true;//from  w ww . java2  s .c  o m

    final ImageView imageSMS = (ImageView) dialog.findViewById(R.id.imageDialogSMS);
    imageSMS.setImageResource(R.drawable.icon_sms);

    dialog.show();

    //Retrieve form info
    taxi_id = inputTaxi.getText().toString().toUpperCase();
    taxi_id = taxi_id.replace(" ", "");
    taxi_comp = actv_comp_taxi.getText().toString();
    taxi_driver = taxiDriver.getText().toString();
    taxi_license = taxiLic.getText().toString();
    loc_frm = actv_from.getText().toString();
    loc_to = actv_to.getText().toString();
    dateBus = editDate.getText().toString();
    timeBus = editTime.getText().toString();
    curr_time = editCurrTime.getText().toString();
    user_name = SaveSharedPreference.getUserName(TraqComplaintTaxi.this);

    //Twitter Button
    final RelativeLayout twitterLogin = (RelativeLayout) dialog.findViewById(R.id.twitterImageButton);
    twitterLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTwitterSelected) {
                image.setImageResource(R.drawable.icon_twitter);
                twitterText.setTextColor(getResources().getColor(R.color.DarkGray));
                isTwitterSelected = false;
            } else {
                loginToTwitter();
                image.setImageResource(R.drawable.icon_twitter_blue);
                twitterText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isTwitterSelected = true;
            }

        }
    });

    //facebook Button
    final RelativeLayout facebookLogin = (RelativeLayout) dialog.findViewById(R.id.facebookImageButton);
    facebookLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isFacebookSelected) {
                imageFb.setImageResource(R.drawable.ic_fb_grey);
                if (fbUserName != null)
                    facebookText.setText("Facebook");

                facebookText.setTextColor(getResources().getColor(R.color.DarkGray));
                isFacebookSelected = false;
            } else {

                //loginToTwitter();
                // start Facebook Login
                loginToFacebook();
                if (fbUserName != null)
                    facebookText.setText(fbUserName);
                imageFb.setImageResource(R.drawable.ic_fb_blue);
                facebookText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isFacebookSelected = true;
            }

        }
    });

    //SMS Button
    final RelativeLayout SMSLogin = (RelativeLayout) dialog.findViewById(R.id.smsImageButton);
    SMSLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isSmsSelected) {
                imageSMS.setImageResource(R.drawable.icon_sms);
                smsText.setTextColor(getResources().getColor(R.color.DarkGray));
                isSmsSelected = false;
            } else {
                imageSMS.setImageResource(R.drawable.icon_sms_color);
                smsText.setTextColor(getResources().getColor(R.color.Orange));
                isSmsSelected = true;
            }

        }
    });

    /*/Default Button
    final RelativeLayout defaultLogin = (RelativeLayout)dialog.findViewById(R.id.defaultImageButton);
    defaultLogin.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(isDefaultSelected)
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = false;
        }
        else
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = true;
        }
            
    }
    });*/

    //Submit Button
    Button declineButton = (Button) dialog.findViewById(R.id.submitButton);
    // if decline button is clicked, close the custom dialog
    declineButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //submit complaint
            isSubmitButtonClicked = true;
            if (isNetworkConnected() == true) {
                Toast.makeText(TraqComplaintTaxi.this, "Complaint sent. Thank you for taking action!",
                        Toast.LENGTH_SHORT).show();

                //Combine Strings for Twitter Status

                String status = taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed
                        + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude)
                        + "E, " + curr_time + " @aduanSPAD @MyTraquer #Traquer";

                finalStatus = status;

                if (isFacebookSelected) {
                    //share to facebook
                    ShareToFacebook(status);
                    //publishFeedDialog();
                }

                if (isTwitterSelected) {

                    //Toast.makeText(TraqComplaintTaxi.this, Long.toString(twitterID) + userName, Toast.LENGTH_SHORT).show();

                    // Check for blank text
                    if (status.trim().length() > 0) {
                        // update status
                        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) {
                            new updateTwitterStatus().execute(status);
                        }

                        else
                            new updateTwitterStatus().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, status);

                    } else {
                        // EditText is empty
                        Toast.makeText(getApplicationContext(), "Please enter status message",
                                Toast.LENGTH_SHORT).show();
                    }

                } else {
                    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1)
                        new InsertForm().execute();
                    else
                        new InsertForm().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

                }

                // Close dialog
                dialog.dismiss();

            } else {
                if (isSmsSelected) {
                    Log.i("Clicks", "You clicked sent.");

                    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                    sendIntent.putExtra("address", "15888");
                    sendIntent.putExtra("sms_body",
                            "SPAD Aduan " + taxi_id + ", " + taxi_comp + " taxi is speeding with "
                                    + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, "
                                    + Double.toString(gLongitude) + "E, " + curr_time + " - Traquer");
                    sendIntent.setType("vnd.android-dir/mms-sms");
                    startActivity(sendIntent);

                    //1800-88-7723
                } else {
                    Toast.makeText(TraqComplaintTaxi.this,
                            "Failed to send. Please check your network connection.", Toast.LENGTH_SHORT).show();
                }
            }

        }

    });
    //TraqComplaintTaxi.this.showDialog(ALERT_DIALOG);
}

From source file:bill.billmanager.Adapters.SlidingTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*from  w ww . j ava2 s  .  c om*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

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

        // Sets tab's text color and size
        tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector));
        tabTitleView.setTextSize(14);
    }
}

From source file:com.antonborries.bulktask.SlidingTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from  w w w  . ja v  a2  s  .c om
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTag("titleView_" + String.valueOf(i));
        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);
        }

        tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector));
        tabTitleView.setTextSize(14);
    }
}

From source file:com.android.calendar.selectcalendars.SelectCalendarsSimpleAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (position >= mRowCount) {
        return null;
    }/*from  w  ww. ja va  2s .c o m*/
    String name = mData[position].displayName;
    boolean selected = mData[position].selected;

    int color = Utils.getDisplayColorFromColor(mData[position].color);
    View view;
    if (convertView == null) {
        view = mInflater.inflate(mLayout, parent, false);
        final View delegate = view.findViewById(R.id.color);
        final View delegateParent = (View) delegate.getParent();
        delegateParent.post(new Runnable() {

            @Override
            public void run() {
                final Rect r = new Rect();
                delegate.getHitRect(r);
                r.top -= mColorViewTouchAreaIncrease;
                r.bottom += mColorViewTouchAreaIncrease;
                r.left -= mColorViewTouchAreaIncrease;
                r.right += mColorViewTouchAreaIncrease;
                delegateParent.setTouchDelegate(new TouchDelegate(r, delegate));
            }
        });
    } else {
        view = convertView;
    }

    TextView calendarName = (TextView) view.findViewById(R.id.calendar);
    calendarName.setText(name);

    View colorView = view.findViewById(R.id.color);
    colorView.setBackgroundColor(color);
    colorView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Purely for sanity check--view should be disabled if account has no more colors
            if (!hasMoreColors(position)) {
                return;
            }

            if (mColorPickerDialog == null) {
                mColorPickerDialog = CalendarColorPickerDialog.newInstance(mData[position].id, mIsTablet);
            } else {
                mColorPickerDialog.setCalendarId(mData[position].id);
            }
            mFragmentManager.executePendingTransactions();
            if (!mColorPickerDialog.isAdded()) {
                mColorPickerDialog.show(mFragmentManager, COLOR_PICKER_DIALOG_TAG);
            }
        }
    });

    int textColor;
    if (selected) {
        textColor = mColorCalendarVisible;
    } else {
        textColor = mColorCalendarHidden;
    }
    calendarName.setTextColor(textColor);

    CheckBox syncCheckBox = (CheckBox) view.findViewById(R.id.sync);
    if (syncCheckBox != null) {

        // Full screen layout
        syncCheckBox.setChecked(selected);

        colorView.setEnabled(hasMoreColors(position));
        LayoutParams layoutParam = calendarName.getLayoutParams();
        TextView secondaryText = (TextView) view.findViewById(R.id.status);
        if (!TextUtils.isEmpty(mData[position].ownerAccount) && !mData[position].ownerAccount.equals(name)
                && !mData[position].ownerAccount.endsWith("calendar.google.com")) {
            int secondaryColor;
            if (selected) {
                secondaryColor = mColorCalendarSecondaryVisible;
            } else {
                secondaryColor = mColorCalendarSecondaryHidden;
            }
            secondaryText.setText(mData[position].ownerAccount);
            secondaryText.setTextColor(secondaryColor);
            secondaryText.setVisibility(View.VISIBLE);
            layoutParam.height = LayoutParams.WRAP_CONTENT;
        } else {
            secondaryText.setVisibility(View.GONE);
            layoutParam.height = LayoutParams.MATCH_PARENT;
        }

        calendarName.setLayoutParams(layoutParam);

    } else {
        // Tablet layout
        view.findViewById(R.id.color).setEnabled(selected && hasMoreColors(position));
        view.setBackgroundDrawable(getBackground(position, selected));
        ViewGroup.LayoutParams newParams = view.getLayoutParams();
        if (position == mData.length - 1) {
            newParams.height = BOTTOM_ITEM_HEIGHT;
        } else {
            newParams.height = NORMAL_ITEM_HEIGHT;
        }
        view.setLayoutParams(newParams);
        CheckBox visibleCheckBox = (CheckBox) view.findViewById(R.id.visible_check_box);
        if (visibleCheckBox != null) {
            visibleCheckBox.setChecked(selected);
        }
    }
    view.invalidate();
    return view;
}

From source file:com.citylifeezy.citylifeezy.SlidingTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//  ww w .j  ava2s. c  o  m
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        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);
            //tabTitleView.setTextColor(getResources().getColor(R.color.dismiss_color));
        }
        tabTitleView.setTextColor(getResources().getColor(R.color.white));
    }
}

From source file:terse.a1.TerseActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    glSurfaceView = null; // Forget gl on new activity.

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (savedInstanceState != null && savedInstanceState.containsKey("TerseActivity")) {
        taSaveMe = savedInstanceState.getString("TerseActivity");
    } else {/*from www  .  j av  a2 s  . c om*/
        taSaveMe = null;
    }

    Runnable bg = new Runnable() {
        @Override
        public void run() {
            resetTerp();
        }
    };

    Runnable fg = new Runnable() {
        @Override
        public void run() {
            Intent intent = getIntent();
            Uri uri = intent.getData();
            Bundle extras = intent.getExtras();
            String path = uri == null ? "/" : uri.getPath();
            String query = uri == null ? "" : uri.getQuery();

            viewPath(path, query, extras, savedInstanceState);
        }
    };
    if (terp == null) {
        TextView tv = new TextView(TerseActivity.this);
        tv.setText(Static.fmt("Building new TerseTalk VM for world <%s>...", world));
        tv.setTextAppearance(this, R.style.teletype);
        tv.setBackgroundColor(Color.BLACK);
        tv.setTextColor(Color.DKGRAY);
        tv.setTextSize(24);
        setContentView(tv);
        setContentViewThenBgThenFg("ResetSplash", tv, bg, fg);
    } else {
        fg.run();
    }
}

From source file:terse.a1.TerseActivity.java

public void viewPath(String path, String queryStr, Bundle extras, Bundle savedInstanceState) {
    // Stop any running WorkThread before we continue.
    viewPath1prepare(path, queryStr);//  w  w  w  .j  a  v  a  2s .  co m
    viewPath2parseQuery(queryStr, extras);

    final LayoutParams widgetParams = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT, 1.0f);

    TextView splash = new TextView(TerseActivity.this);
    splash.setText("Launching\n\n" + taPath + "\n\n" + Static.hashMapToMultiLineString(taQuery));
    splash.setTextAppearance(this, R.style.teletype);
    splash.setBackgroundColor(Color.BLACK);
    splash.setTextColor(Color.DKGRAY);
    splash.setTextSize(24);

    Runnable bg = new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    };

    Runnable fg = new Runnable() {
        @Override
        public void run() {
            viewPath9display(taPath, widgetParams);
        }
    };

    setContentViewThenBgThenFg("viewPath8", splash, bg, fg);
}

From source file:com.example.SmartBoard.DrawingView.java

public Bitmap textToBitmap(String text, int color, float posX, float posY, int size) {
    TextView textView = new TextView(getContext());
    textView.setVisibility(View.VISIBLE);
    textView.setTextColor(color);
    textView.setMaxWidth(500);// w w w. ja v a  2 s  .  com
    textView.setMaxHeight(500);
    textView.setMaxLines(4);
    textView.setX(posX);
    textView.setY(posY);
    textView.setText(text);
    textView.setTextSize(size);

    LinearLayout layout = new LinearLayout(getContext());
    layout.addView(textView);
    layout.measure(500, 500);
    layout.layout(0, 0, 500, 500);

    textView.setDrawingCacheEnabled(true);
    textView.buildDrawingCache();
    Bitmap bm = textView.getDrawingCache();
    return bm;
}