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.flipzu.flipzu.Player.java

private void updateBanner(String msg, int color) {
    final TextView timer_tv = (TextView) findViewById(R.id.timer);
    timer_tv.setTextColor(color);
    timer_tv.setText(msg);/* w w w.  j  a  va  2 s .  co  m*/
}

From source file:cn.caimatou.canting.widget.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 = null;/*from   www  .  j a  v a 2s  .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));
        // set text color
        tabTitleView.setTextColor(mTextColor);
        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:edu.cens.loci.ui.PlaceViewActivity.java

private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) {

    ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>();

    HashMap<String, APInfoMapItem> apMap = wifi.getAps();
    Set<String> keys = apMap.keySet();
    Iterator<String> iter = keys.iterator();
    while (iter.hasNext()) {
        String bssid = iter.next();
        APInfoMapItem ap = apMap.get(bssid);
        items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets));
    }//  w ww  .j a  v a2  s  .  c om

    Collections.sort(items);

    table.setColumnCollapsed(0, false);
    table.setColumnCollapsed(1, true);
    table.setColumnShrinkable(0, true);

    for (int i = 0; i < mAddedRows.size(); i++) {
        table.removeView(mAddedRows.get(i));
    }
    mAddedRows.clear();

    int totalCount = wifi.getScanCount();

    for (WifiViewListItem item : items) {
        TableRow row = new TableRow(this);

        TextView ssidView = new TextView(this);
        ssidView.setText(item.ssid);
        //ssidView.setText("very very very veryvery very very very very very");
        ssidView.setPadding(2, 2, 2, 2);
        ssidView.setTextColor(0xffffffff);

        TextView bssidView = new TextView(this);
        bssidView.setText(item.bssid);
        bssidView.setPadding(2, 2, 2, 2);
        bssidView.setTextColor(0xffffffff);

        TextView cntView = new TextView(this);
        cntView.setText("" + (item.count * 100) / totalCount);
        cntView.setPadding(2, 2, 2, 2);
        cntView.setGravity(Gravity.CENTER);
        cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        TextView rssView = new TextView(this);
        rssView.setText("" + item.rss);
        rssView.setPadding(2, 2, 6, 2);
        rssView.setGravity(Gravity.CENTER);
        rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        row.addView(ssidView, new TableRow.LayoutParams(0));
        row.addView(bssidView, new TableRow.LayoutParams(1));
        row.addView(cntView, new TableRow.LayoutParams(2));
        row.addView(rssView, new TableRow.LayoutParams(3));

        //Log.d(TAG, item.ssid);
        for (int i = 0; i < item.rssBuckets.length; i++) {
            TextView box = new TextView(this);
            box.setText("  ");
            box.setGravity(Gravity.RIGHT);
            box.setPadding(2, 2, 2, 2);
            box.setHeight(15);
            box.setGravity(Gravity.CENTER_VERTICAL);

            float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount());
            //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]);
            int colorValInt = ((int) colorVal) - 1;
            if (colorValInt < 0)
                colorValInt = 0;

            box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan));
            box.setTextColor(0xffffffff);

            row.addView(box, new TableRow.LayoutParams(4 + i));
        }

        row.setGravity(Gravity.CENTER);

        table.addView(row, new TableLayout.LayoutParams());
        table.setColumnStretchable(3, true);
        mAddedRows.add(row);
    }

}

From source file:com.arya.portfolio.view_controller.fragment.UseCasesFragment.java

private void setViewSelected(TextView selectedView) {
    selectedView.setTextColor(ContextCompat.getColor(Env.appContext, R.color.color_white));
    selectedView.setBackgroundColor(ContextCompat.getColor(Env.appContext, R.color.color_light_green));
    selectedView.setSelected(true);//from w  ww .java  2  s.com
    txtLastSelectedView = selectedView;
}

From source file:com.money.manager.ex.home.HomeFragment.java

private void addFooterToExpandableListView(double curTotal, double curReconciled) {
    // manage footer list view
    if (linearFooter == null) {
        linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills,
                null);//from   ww  w .  j  a  v  a 2 s.  c om
        // text view into layout
        txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textViewItemAccountTotal);
        txtFooterSummaryReconciled = (TextView) linearFooter
                .findViewById(R.id.textViewItemAccountTotalReconciled);
        if (mHideReconciled) {
            txtFooterSummaryReconciled.setVisibility(View.GONE);
        }
        // set text
        TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textViewItemAccountName);
        txtTextSummary.setText(R.string.summary);
        // invisible image
        ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType);
        imgSummary.setVisibility(View.INVISIBLE);
        // set color textview
        txtTextSummary.setTextColor(Color.GRAY);
        txtFooterSummary.setTextColor(Color.GRAY);
        if (!mHideReconciled) {
            txtFooterSummaryReconciled.setTextColor(Color.GRAY);
        }
    }
    // remove footer
    mExpandableListView.removeFooterView(linearFooter);
    // set text
    txtTotalAccounts.setText(mCurrencyService.getBaseCurrencyFormatted(MoneyFactory.fromDouble(curTotal)));
    txtFooterSummary.setText(txtTotalAccounts.getText());
    if (!mHideReconciled) {
        txtFooterSummaryReconciled
                .setText(mCurrencyService.getBaseCurrencyFormatted(MoneyFactory.fromDouble(curReconciled)));
    }
    // add footer
    mExpandableListView.addFooterView(linearFooter, null, false);
}

From source file:fr.cph.chicago.activity.BusActivity.java

/**
 * Draw arrivals in current layout//  w ww  . j a  v  a2 s.  c o  m
 */
public final void drawArrivals() {
    if (mBusArrivals != null) {
        Map<String, TextView> mapRes = new HashMap<String, TextView>();
        if (this.mBusArrivals.size() != 0) {
            for (BusArrival arrival : this.mBusArrivals) {
                if (arrival.getRouteDirection().equals(mBound)) {
                    String destination = arrival.getBusDestination();
                    if (mapRes.containsKey(destination)) {
                        TextView arrivalView = mapRes.get(destination);
                        if (arrival.getIsDly()) {
                            arrivalView.setText(arrivalView.getText() + " Delay");
                        } else {
                            arrivalView.setText(arrivalView.getText() + " " + arrival.getTimeLeft());
                        }
                    } else {
                        TextView arrivalView = new TextView(ChicagoTracker.getAppContext());
                        if (arrival.getIsDly()) {
                            arrivalView.setText(arrival.getBusDestination() + ": Delay");
                        } else {
                            arrivalView.setText(arrival.getBusDestination() + ": " + arrival.getTimeLeft());
                        }
                        arrivalView.setTextColor(
                                ChicagoTracker.getAppContext().getResources().getColor(R.color.grey));
                        mapRes.put(destination, arrivalView);
                    }
                }
            }
        } else {
            TextView arrivalView = new TextView(ChicagoTracker.getAppContext());
            arrivalView.setTextColor(ChicagoTracker.getAppContext().getResources().getColor(R.color.grey));
            arrivalView.setText("No service scheduled");
            mapRes.put("", arrivalView);
        }
        mStopsView.removeAllViews();
        for (Entry<String, TextView> entry : mapRes.entrySet()) {
            mStopsView.addView(entry.getValue());
        }

    }
}

From source file:com.photon.phresco.nativeapp.eshop.activity.ProductDetailActivity.java

/**
 * Create the details sections at the bottom of the screen dynamically
 *
 * @param details// w  w  w .  j a  va2s . c  o  m
 * @throws NumberFormatException
 */
private void renderProdcutDetails(Map<String, String> details) {

    try {
        LinearLayout tl = (LinearLayout) findViewById(R.id.product_details_layout);
        int totalDetails = details.size();
        int cnt = 1;
        PhrescoLogger.info(TAG + "renderProdcutDetails() - totalDetails : " + totalDetails);
        TextView lblDetailLabel = null;
        for (Entry<String, String> entry : details.entrySet()) {

            // Create a TextView to hold the label for product detail
            lblDetailLabel = new TextView(this);
            if (cnt == 1) {
                lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_top);
            } else if (cnt == totalDetails) {
                lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_bottom);
            } else {
                lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_middle);
            }
            lblDetailLabel.setText(entry.getKey() + ": " + entry.getValue());
            lblDetailLabel.setGravity(Gravity.CENTER);
            lblDetailLabel.setTypeface(Typeface.DEFAULT, style.TextViewStyle);
            lblDetailLabel.setTextColor(Color.WHITE);
            lblDetailLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f));
            tl.addView(lblDetailLabel);
            cnt++;
        }
    } catch (Exception ex) {
        PhrescoLogger.info(TAG + "renderProdcutDetails - Exception : " + ex.toString());
        PhrescoLogger.warning(ex);
    }
}

From source file:com.appybite.customer.AllowedHotels.java

private void unselectHotels() {
    for (int j = 0; j < llHotelList.getChildCount(); j++) {

        View item = llHotelList.getChildAt(j);
        TextView tvTitle = (TextView) item.getTag();
        tvTitle.setTextColor(getResources().getColor(R.color.White));
    }/* w w  w. ja v a2  s  .co m*/
}

From source file:be.digitalia.fosdem.widgets.SlidingTabLayout.java

private void populateTabStrip() {
    final int adapterCount = mAdapter.getCount();
    final View.OnClickListener tabClickListener = new TabClickListener();
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    final int currentItem = mViewPager.getCurrentItem();

    for (int i = 0; i < adapterCount; i++) {
        View tabView;/*  w w w . j  a  v  a  2  s.  c o m*/
        TextView tabTitleView;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            if (tabTitleView == null) {
                tabTitleView = (TextView) tabView;
            }
        } else {
            // Inflate our default tab layout
            tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false);
            tabTitleView = (TextView) tabView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                // Emulate Roboto Medium in previous Android versions
                tabTitleView.setTypeface(Typeface.DEFAULT_BOLD);
            }
        }
        if (mTextColor != null) {
            tabTitleView.setTextColor(mTextColor);
        }

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

        tabTitleView.setText(mAdapter.getPageTitle(i));
        tabView.setFocusable(true);
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
        if (i == currentItem) {
            tabView.setSelected(true);
        }
    }
}

From source file:com.justone.android.main.MainActivity.java

@SuppressWarnings("deprecation")
@Override/*from w ww.j  a v  a 2 s.  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    currentContext = this;
    //listviewview
    this.viewMap = new HashMap<String, ListViewAdapter>();
    //
    this.asynImageLoader = JustOne.getAsynImageLoader();
    this.dataOp = JustOne.getDataOp();

    //
    this.res = getResources(); // Resource object to get Drawables  

    // 
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
            .detectNetwork().penaltyLog().build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());

    justOne = (JustOne) getApplication();
    justOne.pushActivity(this);
    // view
    LayoutInflater inflater = LayoutInflater.from(this);
    //details_page_setitem = inflater.inflate(R.layout.one_details_page_setitem, null);
    main_item = inflater.inflate(R.layout.activity_main, null);
    bind_item = inflater.inflate(R.layout.one_details_page_binditem, null);
    about_one = inflater.inflate(R.layout.about_one, null);
    //microblog = inflater.inflate(R.layout.one_details_page_microblog, null);

    feedback = inflater.inflate(R.layout.feedback, null);

    setContentView(main_item);

    initData();

    // view
    mListView = (ListView) findViewById(R.id.tab2);
    //ArrayList<ArrayList<String>> list_data = loadData("list",data);
    listAdapter = new ListViewAdapter(this, mList, mGist, R.id.scrollview, R.layout.list_item);

    mListView.setAdapter(listAdapter);

    /*
    mListView1 = (ListView) findViewById(R.id.tab1);
            
    //ArrayList<ArrayList<String>> collect_data = loadData("collect",data);
    collectAdapter = new ListViewAdapter(this,mList,
    mGist, R.id.collectScrollview,
    R.layout.collect_item);
            
    mListView1.setAdapter(collectAdapter);
    */
    homeListView = (ListView) findViewById(R.id.homeTab);
    homeAdapter = new ListViewAdapter(this, mList, mGist, R.id.homeScrollView, R.layout.home_item);

    homeListView.setAdapter(homeAdapter);

    qaListView = (ListView) findViewById(R.id.QAtab);

    //ArrayList<ArrayList<String>> QA_data = loadData("QA",data);
    QAAdapter = new ListViewAdapter(this, mList, mGist, R.id.qaScrollView, R.layout.qa_item);

    qaListView.setAdapter(QAAdapter);

    //detailView = (ListView) findViewById(R.id.tab3);

    //ArrayList<ArrayList<String>> detail_data = loadData("detail",data);
    //detailAdapter = new ListViewAdapter(this,
    //      mList, mGist,
    //      R.id.detailScrollView, R.layout.detail_item);

    //detailView.setAdapter(detailAdapter);

    /*//loading list view 
    loadingView = (ListView) findViewById(R.id.loading_view);
            
    //ArrayList<ArrayList<String>> detail_data = loadData("detail",data);
    loadingAdapter = new ListViewAdapter(this,
    mList, mGist,
    R.id.loadingScrollView, R.layout.one_welcome_ad);
            
    loadingView.setAdapter(loadingAdapter);
            
    */

    tabs = (TabHost) findViewById(R.id.tabhost);
    tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    int width = 100;
    int height = 100;
    tabs.setup();
    tabs.addTab(tabs.newTabSpec("home tab").setIndicator("", this.res.getDrawable(R.drawable.home_tab_selector))
            .setContent(R.id.homeTab));
    tabs.addTab(tabs.newTabSpec("list tab").setIndicator("", this.res.getDrawable(R.drawable.one_tab_selector))
            .setContent(R.id.tab2));
    tabs.addTab(tabs.newTabSpec("QA Tab").setIndicator("", this.res.getDrawable(R.drawable.qa_tab_selector))
            .setContent(R.id.QAtab));

    /*
    tabs.addTab(tabs.newTabSpec("second tab").setIndicator("", null)
    .setContent(R.id.tab1));*/
    //tabs.addTab(tabs.newTabSpec("second tab").setIndicator("",this.res.getDrawable(R.drawable.more_tab_selector))
    //      .setContent(R.id.tab3));

    tabs.setCurrentTab(0);
    for (int i = 0; i < tabWidget.getChildCount(); i++) {
        /**
         * fill_parent
         */
        tabWidget.getChildAt(i).getLayoutParams().height = height;
        tabWidget.getChildAt(i).getLayoutParams().width = width;

        /**
         * tab
         */
        final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
        tv.setTextColor(this.getResources().getColorStateList(android.R.color.white));
        tv.setTextSize(15);
        tv.setGravity(Gravity.TOP);
    }
    mActivityName = getString(R.string.activity_c_label);
    mStatusTracker.setStatus(mActivityName, getString(R.string.on_create));
    Utils.printStatus(mStatusView, mStatusAllView);
    detector = new GestureDetector(this);
    viewMap.put("home", this.homeAdapter);

    //
    View returnBackToIndex = main_item.findViewById(R.id.returnBackToIndex_layout);
    returnBackToIndex.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            MainActivity.this.finish();
            // TODO Auto-generated method stub

        }
    });

    userFirstTips();

}