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.gammalabs.wifianalyzer.wifi.AccessPointDetail.java

private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());
    ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s",
            wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance))
            .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance()));

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {/*from  www  .  ja  va  2  s. c o m*/
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }
}

From source file:com.vrem.wifianalyzer.wifi.accesspoint.AccessPointDetail.java

private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.getImageResource());
    securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());
    ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s",
            wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance))
            .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance()));

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {//from  w  ww  . j  av a  2  s.  c  om
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }
}

From source file:am.project.x.business.widgets.indicatortabstrip.IndicatorTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);
        views.add(text);/*from  w ww.  j av  a2  s . c om*/
    }
    return views;
}

From source file:com.vrem.wifianalyzer.wifi.AccessPointDetail.java

private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource()));

    //SET CHANNEL
    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());

    ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s",
            wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS));

    ((TextView) view.findViewById(R.id.distance))
            .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance()));

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {/*from   w  w  w .j av  a  2 s. c  om*/
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }
}

From source file:com.dedipower.portal.android.ManagedServerLanding.java

public void UpdateErrorMessage(String MessageText) {
    TextView ErrorMessage = (TextView) findViewById(R.id.ErrorMessageText);
    ErrorMessage.setTextColor(-65536);
    ErrorMessage.setText(MessageText);/*from ww w.j  a  v a2s  .  c  o  m*/
}

From source file:com.f16gaming.pathofexilestatistics.PoeEntry.java

public AlertDialog getInfoDialog(Activity activity, Resources res) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.info, null);
    String nameFormat = res.getString(R.string.info_name);
    String accountFormat = res.getString(R.string.info_account);
    String rankFormat = res.getString(R.string.info_rank);
    String levelFormat = res.getString(R.string.info_level);
    String classFormat = res.getString(R.string.info_class);
    String experienceFormat = res.getString(R.string.info_experience);
    ((TextView) view.findViewById(R.id.info_name)).setText(String.format(nameFormat, name));
    ((TextView) view.findViewById(R.id.info_account)).setText(String.format(accountFormat, account));
    ((TextView) view.findViewById(R.id.info_rank)).setText(String.format(rankFormat, rank));
    ((TextView) view.findViewById(R.id.info_level)).setText(String.format(levelFormat, level));
    ((TextView) view.findViewById(R.id.info_class)).setText(String.format(classFormat, className));
    ((TextView) view.findViewById(R.id.info_experience)).setText(String.format(experienceFormat, experience));

    TextView status = (TextView) view.findViewById(R.id.info_status);
    status.setText(online ? R.string.online : R.string.offline);
    status.setTextColor(online ? res.getColor(R.color.online) : res.getColor(R.color.offline));

    builder.setTitle(R.string.info_title).setView(view).setPositiveButton(android.R.string.ok,
            new DialogInterface.OnClickListener() {
                @Override//from w ww  . j  a v  a2  s  .  c o m
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    return builder.create();
}

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

private void setSelectedTextColor(int position) {
    for (TextView tab : tabs) {
        tab.setTextColor(getResources().getColor(textColorId));
    }//from   w  ww .  j a v  a2 s .  co  m
    tabs.get(position).setTextColor(getResources().getColor(selectedTextColorId));
}

From source file:com.buddi.client.dfu.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);//from  w w  w.ja  v  a  2  s.c  o m
        mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    mcpItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            Intent action = mcpIntent;
            if (mcpInfo == null)
                action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
            action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            try {
                startActivity(action);
            } catch (final ActivityNotFoundException e) {
                Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
            }
            mDrawerLayout.closeDrawers();
        }
    });

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mDrawerLayout.closeDrawers();
            }
        });
        container.addView(item);
    }
}

From source file:ca.farrelltonsolar.classic.DayLogCalendar.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    theView = inflater.inflate(R.layout.day_log_calendar, container, false);
    Bundle args = getArguments();/*  w  w w  .ja  v a  2s .c o m*/
    int monthOffset = args != null ? args.getInt(ARG_MONTH) : 0;
    month = DateTime.now().minusMonths(monthOffset).withTimeAtStartOfDay().withDayOfMonth(1);
    adapter = new CalendarAdapter(this.getActivity(), month);
    GridView gridview = (GridView) theView.findViewById(R.id.gridview);
    gridview.setAdapter(adapter);
    gridview.setVelocityScale(5);

    TextView title = (TextView) theView.findViewById(R.id.title);
    title.setText(month.toString("MMMM yyyy"));
    View linearLayout = theView.findViewById(R.id.headerlayout);
    DateTime days = month;

    for (int i = 0; i < 7; i++) {
        int d = ((i + 6) % 7) + 1;
        days = days.withDayOfWeek(d);
        TextView aDay = new TextView(theView.getContext());
        aDay.setText(DateTimeFormat.forPattern("E").print(days));
        aDay.setGravity(Gravity.CENTER);
        aDay.setTextColor(Color.BLACK);
        aDay.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        ((LinearLayout) linearLayout).addView(aDay);

    }

    return theView;
}

From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetail.java

public void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean child, boolean frequencyRange) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    TextView textIPAddress = (TextView) view.findViewById(R.id.ipAddress);
    TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed);
    String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress();
    if (StringUtils.isBlank(ipAddress)) {
        textIPAddress.setVisibility(View.GONE);
        textLinkSpeed.setVisibility(View.GONE);
    } else {/*from   ww w  .  j  ava  2s .c o m*/
        textIPAddress.setVisibility(View.VISIBLE);
        textIPAddress.setText(ipAddress);

        int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed();
        if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) {
            textLinkSpeed.setVisibility(View.GONE);
        } else {
            textLinkSpeed.setVisibility(View.VISIBLE);
            textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS));
        }
    }

    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    if (wiFiDetail.getWiFiAdditional().isConfiguredNetwork()) {
        configuredImage.setVisibility(View.VISIBLE);
        configuredImage.setColorFilter(resources.getColor(R.color.connected));
    } else {
        configuredImage.setVisibility(View.GONE);
    }

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();
    ImageView imageView = (ImageView) view.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.imageResource());
    imageView.setColorFilter(resources.getColor(strength.colorResource()));

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(resources.getColor(R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(resources.getColor(strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel))
            .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel()));
    ((TextView) view.findViewById(R.id.frequency))
            .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance()));
    ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities());

    TextView textVendor = ((TextView) view.findViewById(R.id.vendor));
    String vendor = wiFiDetail.getWiFiAdditional().getVendorName();
    if (StringUtils.isBlank(vendor)) {
        textVendor.setVisibility(View.GONE);
    } else {
        textVendor.setVisibility(View.VISIBLE);
        textVendor.setText(vendor);
    }

    if (child) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }

    if (frequencyRange) {
        view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.VISIBLE);
        ((TextView) view.findViewById(R.id.channel_frequency_range)).setText(String.format("%d - %d %s",
                wiFiSignal.getFrequencyStart(), wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS));
    } else {
        view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.GONE);
    }
}