Example usage for android.widget TextView setBackgroundColor

List of usage examples for android.widget TextView setBackgroundColor

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java

private void previewLayout(Context context) {
    setGravity(Gravity.CENTER);//from  w ww.j a v a  2  s . co  m
    TextView tv = new TextView(context);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    tv.setLayoutParams(params);
    tv.setGravity(Gravity.CENTER);
    tv.setText(getClass().getSimpleName());
    tv.setTextColor(Color.WHITE);
    tv.setBackgroundColor(Color.GRAY);
    addView(tv);
}

From source file:jahirfiquitiva.iconshowcase.adapters.ChangelogAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.changelog_content, parent, false);
        convertView.setClickable(false);
        convertView.setLongClickable(false);
        convertView.setFocusable(false);
        convertView.setFocusableInTouchMode(false);
        convertView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
    }/*w  ww  .j  a  va 2 s . c om*/

    TextView title = (TextView) convertView.findViewById(R.id.changelog_title);
    TextView content = (TextView) convertView.findViewById(R.id.changelog_content);
    String nameStr = mChangelog[position][0];
    String contentStr = "";

    for (int i = 1; i < mChangelog[position].length; i++) {
        if (i > 1) {
            // No need for new line on the first item
            contentStr += "\n";
        }
        contentStr += "\u2022 ";
        contentStr += mChangelog[position][i];
    }

    title.setText(nameStr);
    title.setClickable(false);
    title.setLongClickable(false);
    title.setFocusable(false);
    title.setFocusableInTouchMode(false);
    title.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));

    content.setText(contentStr);
    content.setClickable(false);
    content.setLongClickable(false);
    content.setFocusable(false);
    content.setFocusableInTouchMode(false);
    content.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));

    return convertView;
}

From source file:nz.ac.auckland.lablet.script.components.TextComponent.java

@Override
public View createView(Context context, android.support.v4.app.Fragment parent) {
    // we have to get a fresh counter here, if we cache it we will miss that it has been deleted in the sheet
    // component/*from w  ww  . j a v a  2s  . c  o  m*/
    ScriptTreeNodeSheetBase.Counter counter = this.component.getCounter("QuestionCounter");

    TextView textView = new TextView(context);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        textView.setTextAppearance(android.R.style.TextAppearance_Medium);
        textView.setBackgroundColor(
                context.getResources().getColor(R.color.sc_question_background_color, null));
    } else {
        textView.setTextAppearance(context, android.R.style.TextAppearance_Medium);
        textView.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color));
    }

    textView.setText("Q" + counter.increaseValue() + ": " + text);
    return textView;
}

From source file:project.pamela.slambench.fragments.RankPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.rank_plot, container, false);

    TextView oclLegend = (TextView) llLayout.findViewById(R.id.oclLegend);
    TextView cppLegend = (TextView) llLayout.findViewById(R.id.cppLegend);
    TextView otherLegend = (TextView) llLayout.findViewById(R.id.otherLegend);
    TextView yoursLegend = (TextView) llLayout.findViewById(R.id.yoursLegend);

    oclLegend.setBackgroundColor(getResources().getColor(R.color.oclLegendColor));
    cppLegend.setBackgroundColor(getResources().getColor(R.color.cppLegendColor));
    otherLegend.setBackgroundColor(getResources().getColor(R.color.othersLegendColor));
    yoursLegend.setBackgroundColor(getResources().getColor(R.color.yoursLegendColor));

    /*/*from w w w  . j  a  v  a  2s. co m*/
    if (SLAMBenchApplication.getBenchmark() == null) {
    // Need to run the configuration download ....
    try {
        InputStream inputStream = this.getActivity().getAssets().open("demo.xml");
        SLAMBenchXmlParser parser = new SLAMBenchXmlParser();
        SLAMConfiguration entries = parser.parse(inputStream);
        inputStream.close();
        SLAMBenchApplication.setBenchmark(new SLAMBench(entries));
        if (entries == null ) {
            Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error));
        }
    } catch (IOException e) {
        Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error), e);
    } catch (XmlPullParserException e) {
        Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error), e);
    }
            
    }
    */

    if (SLAMBenchApplication.getBenchmark() == null) {
        return llLayout;
    }

    List<SLAMRank> ranks = SLAMBenchApplication.getBenchmark().getDevicesRank();

    values = new Double[ranks.size() + 1];
    devices = new String[ranks.size() + 1];
    versions = new String[ranks.size() + 1];

    for (int i = 0; i < ranks.size(); i++) {
        SLAMRank r = ranks.get(i);
        values[i] = r.get_result();
        devices[i] = r.get_device();

        versions[i] = (r.get_test() == null) ? "" : r.get_test().name;
    }

    double best = SLAMBenchApplication.getBenchmark().getBestSpeed();

    values[values.length - 1] = (best <= 0) ? 0 : 1.0 / best;
    devices[values.length - 1] = YOUR_DEVICE;
    if (SLAMBenchApplication.getBenchmark() != null
            && SLAMBenchApplication.getBenchmark().getBestResult() != null
            && SLAMBenchApplication.getBenchmark().getBestResult().test != null) {
        versions[values.length - 1] = SLAMBenchApplication.getBenchmark().getBestResult().test.name;
    } else {
        versions[values.length - 1] = "";
    }
    for (int n = 0; n < values.length; n++) {
        for (int m = 0; m < values.length - 1 - n; m++) {
            if ((values[m].compareTo(values[m + 1])) <= 0) {
                String swapString = devices[m];
                devices[m] = devices[m + 1];
                devices[m + 1] = swapString;
                swapString = versions[m];
                versions[m] = versions[m + 1];
                versions[m + 1] = swapString;
                Double swapInt = values[m];
                values[m] = values[m + 1];
                values[m + 1] = swapInt;
            }
        }
    }

    int start = Math.max(0, values.length - RANK_SIZE - 1);
    int end = values.length - 1;

    Log.d(SLAMBenchApplication.LOG_TAG,
            "Default ArrayOfRange(" + Integer.valueOf(start) + "," + Integer.valueOf(end) + ")");

    for (int i = 0; i < values.length; i++) {
        if (devices[i].equals(YOUR_DEVICE)) {
            start = Math.max(0, i - (RANK_SIZE / 2));
            end = Math.min(values.length - 1, start + RANK_SIZE);
            if (end - start < RANK_SIZE) {
                start = Math.max(0, end - RANK_SIZE);
            }
            break;
        }
    }

    Log.d(SLAMBenchApplication.LOG_TAG,
            "ArrayOfRange(" + Integer.valueOf(start) + "," + Integer.valueOf(end) + ")");

    if (best > 0) {
        values = Arrays.copyOfRange(values, start, end);
        devices = Arrays.copyOfRange(devices, start, end);
        versions = Arrays.copyOfRange(versions, start, end);
    } else {
        values = Arrays.copyOf(values, values.length - 1);
        devices = Arrays.copyOf(devices, devices.length - 1);
        versions = Arrays.copyOf(versions, versions.length - 1);
    }
    // initialize our XYPlot reference:
    plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    // colors
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getBorderPaint().setColor(Color.WHITE);
    plot.getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setTextSize(20);
    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT);
    //plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT);

    formatter1 = new MyBarFormatter(getResources().getColor(R.color.othersLegendColor), Color.WHITE);
    openclFormatter = new MyBarFormatter(getResources().getColor(R.color.oclLegendColor), Color.WHITE);
    cppFormatter = new MyBarFormatter(getResources().getColor(R.color.cppLegendColor), Color.WHITE);
    currentFormatter = new MyBarFormatter(getResources().getColor(R.color.yoursLegendColor), Color.WHITE);

    plot.setTicksPerRangeLabel(1);

    //plot.getLayoutManager().remove(plot.getLegendWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());
    plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    plot.getLayoutManager().remove(plot.getRangeLabelWidget());

    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 0.5);

    plot.getGraphWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_LEFT, 0, YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
            AnchorPosition.LEFT_BOTTOM);

    plot.getGraphWidget().setSize(new SizeMetrics(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL));

    plot.setDomainValueFormat(new NumberFormat() {
        @Override
        public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) {
            int index = (int) (value);
            //if ((index) == (value)) {
            //    return new StringBuffer(devices[index]);
            //}
            return new StringBuffer("");
        }

        @Override
        public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) {
            throw new UnsupportedOperationException("Not yet implemented.");
        }

        @Override
        public Number parse(String string, ParsePosition position) {
            throw new UnsupportedOperationException("Not yet implemented.");
        }
    });

    // Setup our Series with the selected number of elements
    series1 = new SimpleXYSeries(Arrays.asList(values), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "devices");

    // add a new series' to the xyplot:
    plot.addSeries(series1, formatter1);

    // Setup the BarRenderer with our selected options
    MyBarRenderer renderer = ((MyBarRenderer) plot.getRenderer(MyBarRenderer.class));
    renderer.setBarRenderStyle(BarRenderer.BarRenderStyle.OVERLAID);
    renderer.setBarWidthStyle(BarRenderer.BarWidthStyle.VARIABLE_WIDTH);
    renderer.setBarWidth(BAR_GAP);
    renderer.setBarGap(BAR_GAP);
    plot.getGraphWidget().setDomainLabelOrientation(-90);

    plot.getGraphWidget().setGridPaddingRight(0);
    plot.getGraphWidget().setGridPaddingTop(0);
    plot.getGraphWidget().setGridPaddingLeft(0);
    plot.getGraphWidget().setGridPaddingBottom(0);

    plot.calculateMinMaxVals();

    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(minXY.x - 0.5, maxXY.x + 0.5, BoundaryMode.FIXED);
    plot.setRangeBoundaries(0, (int) (maxXY.y / 10) * 10f + 10f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:com.glanznig.beepme.view.ViewSampleFragment.java

private void populateFields() {

    if (sampleId != 0L) {
        Sample s = new SampleTable(getActivity().getApplicationContext()).getSampleWithTags(sampleId);

        TextView timestamp = (TextView) getView().findViewById(R.id.view_sample_timestamp);
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        timestamp.setText(dateFormat.format(s.getTimestamp()));

        TextView title = (TextView) getView().findViewById(R.id.view_sample_title);
        if (s.getTitle() != null && s.getTitle().length() > 0) {
            title.setText(s.getTitle());
        } else {//from  w  w  w  .j  a v  a2  s  .  c  o m
            title.setText(getString(R.string.sample_untitled));
        }

        TextView description = (TextView) getView().findViewById(R.id.view_sample_description);
        if (s.getDescription() != null && s.getDescription().length() > 0) {
            description.setTextSize(14);
            description.setText(s.getDescription());
        } else {
            description.setTextSize(12);
            // not editable any more
            if ((Calendar.getInstance().getTimeInMillis() - s.getTimestamp().getTime()) >= 24 * 60 * 60
                    * 1000) {
                description.setText(getString(R.string.sample_no_description));
            } else {
                description.setText(getString(R.string.sample_no_description_editable));
            }
        }

        boolean hasKeywordTags = false;

        FlowLayout keywordHolder = (FlowLayout) getView().findViewById(R.id.view_sample_keyword_container);
        keywordHolder.removeAllViews();

        Iterator<Tag> i = s.getTags().iterator();
        Tag tag = null;

        while (i.hasNext()) {
            tag = i.next();
            if (tag.getVocabularyId() == 1) {

                TextView view = new TextView(getView().getContext());
                view.setText(tag.getName());

                final float scale = getResources().getDisplayMetrics().density;
                int textPaddingLeftRight = 6;
                int textPaddingTopBottom = 2;

                view.setPadding((int) (textPaddingLeftRight * scale + 0.5f),
                        (int) (textPaddingTopBottom * scale + 0.5f),
                        (int) (textPaddingLeftRight * scale + 0.5f),
                        (int) (textPaddingTopBottom * scale + 0.5f));
                view.setBackgroundColor(getResources().getColor(R.color.bg_keyword));

                keywordHolder.addView(view);
                hasKeywordTags = true;
            }
        }

        TextView noKeywordsView = (TextView) getView().findViewById(R.id.view_sample_no_keywords);
        if (!hasKeywordTags) {
            keywordHolder.setVisibility(View.GONE);
            noKeywordsView.setVisibility(View.VISIBLE);
            // not editable any more (after 1 day)
            if ((Calendar.getInstance().getTimeInMillis() - s.getTimestamp().getTime()) >= 24 * 60 * 60
                    * 1000) {
                noKeywordsView.setText(getString(R.string.sample_no_keywords));
            } else {
                noKeywordsView.setText(getString(R.string.sample_no_keywords_editable));
            }
        } else {
            noKeywordsView.setVisibility(View.GONE);
            keywordHolder.setVisibility(View.VISIBLE);
        }

        photoView = (SamplePhotoView) getView().findViewById(R.id.view_sample_photo);
        photoView.setRights(false, false); // read only
        DisplayMetrics metrics = getView().getContext().getResources().getDisplayMetrics();

        int thumbnailSize;
        if (!isLandscape()) {
            photoView.setFrameWidth(LayoutParams.MATCH_PARENT);
            thumbnailSize = (int) (metrics.widthPixels / metrics.density + 0.5f);
        } else {
            thumbnailSize = (int) (metrics.heightPixels / metrics.density + 0.5f);
        }

        String thumbnailUri = PhotoUtils.getThumbnailUri(s.getPhotoUri(), thumbnailSize);
        if (thumbnailUri != null) {
            File thumb = new File(thumbnailUri);
            if (thumb.exists()) {
                ImgLoadHandler handler = new ImgLoadHandler(photoView);
                PhotoUtils.getAsyncBitmap(getView().getContext(), thumbnailUri, handler);
            } else {
                Handler handler = new Handler(this);
                PhotoUtils.generateThumbnails(getView().getContext(), s.getPhotoUri(), handler);
            }
        } else {
            photoView.unsetPhoto();
        }
    }
}

From source file:com.gc.materialdesign.views.PagerSlidingTabStrip.java

public void updateTabStyles(int position) {
    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);
            if (i == position) {
                //  tab.setBackgroundResource(R.drawable.selected_tab_bg);
                tab.setTextColor(tabSelectedTextColor);
                tab.setBackgroundColor(tabSelectedBgColor);
            } else {
                //  tab.setBackgroundColor(getResources().getColor(android.R.color.transparent));
                tab.setTextColor(tabTextColor);
                tab.setBackgroundColor(tabBgColor);
            }/*from  w w w . ja va  2s  .  co m*/
            // 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 source file:org.nla.tarotdroid.lib.ui.GameSetSynthesisFragment.java

/**
  * Refreshes the stats rows on the synthesis view.
  *//*from  www . j a v  a 2s .c  o m*/
protected void refreshPlayerStatsRows() {
    // sort players
    List<Player> sortedPlayers = this.getGameSet().getPlayers().getPlayers();
    Collections.sort(sortedPlayers, new PlayerScoreComparator());

    // get general data sources
    IGameSetStatisticsComputer gameSetStatisticsComputer = GameSetStatisticsComputerFactory
            .GetGameSetStatisticsComputer(this.getGameSet(), "guava");
    MapPlayersScores lastScores = this.getGameSet().getGameSetScores().getResultsAtLastGame();
    Map<Player, Integer> leadingCount = gameSetStatisticsComputer.getLeadingCount();
    Map<Player, Integer> leadingSuccesses = gameSetStatisticsComputer.getLeadingSuccessCount();
    Map<Player, Integer> calledCount = gameSetStatisticsComputer.getCalledCount();
    int minScoreEver = gameSetStatisticsComputer.getMinScoreEver();
    int maxScoreEver = gameSetStatisticsComputer.getMaxScoreEver();

    // format statistics lines
    for (int rank = 0; rank < sortedPlayers.size(); ++rank) {
        // get player specific data sources
        Player player = sortedPlayers.get(rank);
        int lastScore = lastScores == null ? 0 : lastScores.get(player);
        int successfulLeadingGamesCount = leadingSuccesses.get(player) == null ? 0
                : leadingSuccesses.get(player).intValue();
        int leadingGamesCount = leadingCount.get(player) == null ? 0 : leadingCount.get(player);
        int successRate = (int) (((double) successfulLeadingGamesCount) / ((double) leadingGamesCount) * 100.0);
        int minScoreForPlayer = gameSetStatisticsComputer.getMinScoreEverForPlayer(player);
        int maxScoreForPlayer = gameSetStatisticsComputer.getMaxScoreEverForPlayer(player);

        // get line widgets
        LinearLayout statRow = this.statsRows.get(rank + 1);
        //TextView statPlayerName = (TextView)statRow.findViewById(R.id.statPlayerName);
        TextView statScore = (TextView) statRow.findViewById(R.id.statScore);
        TextView statLeadingGamesCount = (TextView) statRow.findViewById(R.id.statLeadingGamesCount);
        TextView statSuccessfulGamesCount = (TextView) statRow.findViewById(R.id.statSuccessfulGamesCount);
        TextView statMinScore = (TextView) statRow.findViewById(R.id.statMinScore);
        TextView statMaxScore = (TextView) statRow.findViewById(R.id.statMaxScore);

        //          Bitmap playerImage = null;
        //          if (player.getPictureUri() != null && !player.getPictureUri().equals("")) {
        //             playerImage = UIHelper.getPlayerImage(this.getActivity(), player);
        //          }
        //          
        //            
        //            // assign values to widgets
        //            if (player.getFacebookId() != null) {
        //             // player facebook image
        //             ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
        //             pictureView.setProfileId(player.getFacebookId());
        //             pictureView.setPresetSize(ProfilePictureView.SMALL);
        //             //pictureView.setOnClickListener(playerClickListener);
        //             pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
        //             statRow.removeViewAt(0);
        //               statRow.addView(pictureView, 0);
        //            }
        //            else {
        //               // WARNING: The properties below reference the style ScoreTextStyle, but we can't set a style at runtime.
        //               TextView playerName = new TextView(this.getActivity());
        //               playerName.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
        //               playerName.setGravity(Gravity.CENTER);
        //               playerName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //               playerName.setEllipsize(TruncateAt.END);
        //               playerName.setSingleLine();
        //               playerName.setTextColor(Color.WHITE);
        //               playerName.setTypeface(null, Typeface.BOLD);
        //               playerName.setText(player.getName());
        //               //playerName.setBackgroundResource(R.drawable.border_player_white);
        //               statRow.removeViewAt(0);
        //               statRow.addView(playerName, 0);
        //            }

        OnClickListener playerClickListener = new PlayerClickListener(player);

        // facebook picture
        if (player.getFacebookId() != null) {
            ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
            pictureView.setProfileId(player.getFacebookId());
            pictureView.setPresetSize(ProfilePictureView.SMALL);
            pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            pictureView.setOnClickListener(playerClickListener);
            //this.addView(pictureView);
            statRow.removeViewAt(0);
            statRow.addView(pictureView, 0);
        }

        // contact picture
        else if (player.getPictureUri() != null
                && player.getPictureUri().toString().contains("content://com.android.contacts/contacts")) {
            Bitmap playerImage = UIHelper.getContactPicture(this.getActivity(),
                    Uri.parse(player.getPictureUri()).getLastPathSegment());
            ImageView imgPlayer = new ImageView(this.getActivity());
            imgPlayer.setImageBitmap(playerImage);
            imgPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            imgPlayer.setOnClickListener(playerClickListener);
            //this.addView(imgPlayer);
            statRow.removeViewAt(0);
            statRow.addView(imgPlayer, 0);
        }

        // no picture, only name
        else {
            TextView txtPlayer = new TextView(this.getActivity());
            txtPlayer.setText(player.getName());
            txtPlayer.setGravity(Gravity.CENTER);
            txtPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
            txtPlayer.setMinWidth(UIConstants.PLAYER_VIEW_WIDTH);
            txtPlayer.setHeight(UIConstants.PLAYER_VIEW_HEIGHT);
            txtPlayer.setBackgroundColor(Color.TRANSPARENT);
            txtPlayer.setTypeface(null, Typeface.BOLD);
            txtPlayer.setTextColor(Color.WHITE);
            txtPlayer.setSingleLine();
            txtPlayer.setEllipsize(TruncateAt.END);

            txtPlayer.setOnClickListener(playerClickListener);
            //this.addView(txtPlayer);
            statRow.removeViewAt(0);
            statRow.addView(txtPlayer, 0);
        }

        statScore.setText(Integer.toString(lastScore));
        statLeadingGamesCount.setText(Integer.toString(leadingGamesCount));
        statSuccessfulGamesCount.setText(
                Integer.toString(successfulLeadingGamesCount) + " (" + Integer.toString(successRate) + "%)");

        // display called game count if necessary 
        if (this.getGameSet().getGameStyleType() == GameStyleType.Tarot5) {
            TextView statCalledGamesCount = (TextView) statRow.findViewById(R.id.statCalledGamesCount);
            statCalledGamesCount
                    .setText(Integer.toString(calledCount.get(player) == null ? 0 : calledCount.get(player)));
        }

        statMinScore.setText(Integer.toString(minScoreForPlayer));
        statMaxScore.setText(Integer.toString(maxScoreForPlayer));
        statMinScore.setTextColor(Color.WHITE);
        statMaxScore.setTextColor(Color.WHITE);

        // color min score if lowest
        if (minScoreEver == minScoreForPlayer) {
            statMinScore.setTextColor(Color.YELLOW);
        }

        // color max score if highest
        if (maxScoreEver == maxScoreForPlayer) {
            statMaxScore.setTextColor(Color.GREEN);
        }
    }
}

From source file:org.mythdroid.activities.Guide.java

/**
 * Generate a TableRow from the provided Channel
 * @param ch Channel to generate a row for
 * @return populated TableRow representing the channel
 *///  ww  w.j a va2  s  . co m
@SuppressLint("DefaultLocale")
private TableRow getRowFromChannel(Channel ch) {

    final TableRow row = new TableRow(this);
    row.setLayoutParams(rowLayout);

    TextView tv = new TextView(this);
    tv.setBackgroundColor(0xffe0e0f0);
    tv.setTextColor(0xff202020);
    tv.setPadding(4, 4, 4, 4);
    tv.setMaxLines(2);
    tv.setTag(ch.ID);
    tv.setText(ch.num + " " + ch.callSign); //$NON-NLS-1$
    tv.setOnClickListener(chanClickListener);
    tv.setOnLongClickListener(chanLongClickListener);
    tv.setLayoutParams(chanLayout);

    row.addView(tv);

    LayoutParams layout = null;

    Program[] progs = ch.programs.toArray(new Program[ch.programs.size()]);
    int numprogs = progs.length;

    for (int i = 0; i < numprogs; i++) {

        if (progs[i].StartTime.equals(later))
            continue;

        tv = new TextView(this);
        layout = new LayoutParams(this, null);
        layout.topMargin = layout.bottomMargin = layout.leftMargin = layout.rightMargin = 1;
        layout.height = rowHeight;

        String cat = catPat.matcher(progs[i].Category.toLowerCase()).replaceAll(""); //$NON-NLS-1$

        try {
            tv.setBackgroundColor(Category.valueOf(cat).color());
        } catch (IllegalArgumentException e) {
            tv.setBackgroundColor(Category.unknown.color());
        }

        tv.setTextColor(0xfff0f0f0);
        tv.setPadding(4, 4, 4, 4);
        tv.setMaxLines(2);
        tv.setText(progs[i].Title);
        setStatusDrawable(tv, progs[i]);

        int width = setLayoutParams(layout, progs[i]) * colWidth;
        if (width < 1)
            continue;

        tv.setWidth(width);
        tv.setLayoutParams(layout);
        tv.setTag(progs[i]);
        tv.setOnClickListener(progClickListener);
        row.addView(tv);

    }

    return row;

}

From source file:com.unkonw.testapp.libs.view.indicator.PagerSlidingTabStrip.java

private void setSelectTextColor(int position) {
    for (int i = 0; i < tabCount; i++) {
        View view = tabsContainer.getChildAt(i);
        if (view instanceof ImageButton) {
        } else if (view instanceof TextView) {
            TextView tabTextView = (TextView) view;

            if (position == i) {
                tabTextView.setTextSize(14);
                selectedBackground(tabTextView);
                tabTextView.setTextColor(getResources().getColor(indexColor));
            } else {
                tabTextView.setBackgroundColor(backGroundColor);
                tabTextView.setTextSize(tabTextSize);
                tabTextView.setTextColor(tabTextColor);
            }/*w  ww  .ja v  a 2  s  .co  m*/
        }
    }
}

From source file:org.mythdroid.activities.Guide.java

/**
 * Get a header row containing column time values
 * @return header TableRow//from w  w w .  ja  v  a2 s.c  o m
 */
private TableRow getHeader() {

    final TableRow row = new TableRow(this, null);
    TextView tv = new TextView(this, null);
    tv.setLayoutParams(hdrDateLayout);
    tv.setPadding(4, 4, 4, 4);
    tv.setBackgroundColor(0xffd0d0ff);
    tv.setTextColor(0xff161616);
    tv.setMaxLines(1);
    tv.setText(hdrDate);
    row.addView(tv);

    int j = 0;

    for (int i = 1; i < times.length; i += hdrSpan) {
        tv = new TextView(this, null);
        tv.setLayoutParams(hdrTimeLayout);
        tv.setPadding(4, 4, 4, 4);
        tv.setBackgroundColor(0xffd0d0ff);
        tv.setTextColor(0xff161616);
        tv.setMaxLines(1);
        tv.setText(hdrTimes[j++]);
        row.addView(tv);
    }

    return row;

}