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.amazonaws.devicefarm.android.referenceapp.Fragments.Tabs.SupplementalUploads.SupplementalUploads_ExtraDataFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity().getApplicationContext(),
            android.R.layout.simple_list_item_1, getDirectoryContents(EXTRA_DATA_PATH)) {
        // Set text color to black
        @Override//from w w w.j ava2s  .  com
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView row = (TextView) super.getView(position, convertView, parent);
            row.setTextColor(Color.BLACK);
            return row;
        }
    };

    setListAdapter(arrayAdapter);
}

From source file:com.baidao.realm_threadexample.AsyncTaskFragment.java

private void showStatus(String txt) {
    Log.i(TAG, txt);//  w  ww  .jav  a 2 s  .com
    TextView tv = new TextView(getActivity());
    tv.setText(txt);
    tv.setTextColor(getResources().getColor(android.R.color.white));
    logsView.addView(tv);
}

From source file:com.achep.base.ui.fragments.dialogs.PermissionsDialog.java

@NonNull
@Override/*from   w ww  . j  a va2 s  .  co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    assert context != null;

    MaterialDialog md = new MaterialDialog.Builder(context).title(R.string.permissions_dialog_title)
            .items(new CharSequence[] { "", "" }).negativeText(R.string.later).build();

    // Make title more red
    TextView title = md.getTitleView();
    title.setTextColor(title.getCurrentTextColor() & 0xFFFF3333 | 0xFF << 16);

    ListView listView = md.getListView();
    assert listView != null;
    mAdapter = new PermissionAdapter(context, new ArrayList<Permission>());
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PermissionAdapter adapter = (PermissionAdapter) parent.getAdapter();
            Permission item = adapter.getItem(position);

            try {
                startActivity(item.getIntentSettings());
            } catch (ActivityNotFoundException e) {
                int msg = item.getErrorResource();
                if (msg != 0)
                    ToastUtils.showLong(getActivity(), msg);
            }
        }
    });

    return md;
}

From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java

@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
    Log.e("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms");
    String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms";
    Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.TOP, 0, 0);
    TextView v = (TextView) mToast.getView().findViewById(android.R.id.message);
    v.setTextColor(Color.RED);
    mToast.show();/* w  w  w.ja va  2  s.c  o  m*/
}

From source file:com.andclient.SetupConnectionActivity.java

private void saveSettingsOnClick(View v) {
    int keyboardPort = 0, mousePort = 0;

    EditText et = (EditText) findViewById(R.id.editTextServerIP);
    String ip = et.getText().toString();
    boolean correctIp = InetAddressUtils.isIPv4Address(ip);
    if (!correctIp) {
        Toast.makeText(SetupConnectionActivity.this, "Server IP is not a correct IPv4 address",
                Toast.LENGTH_SHORT).show();
    }//from  w w w  .  j  ava2s.  c o  m

    et = (EditText) findViewById(R.id.editTextMousePort);
    String txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            mousePort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port is not a number", Toast.LENGTH_SHORT)
                    .show();
        }
        if (mousePort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    et = (EditText) findViewById(R.id.editTextKeyboardPort);
    txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            keyboardPort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be an integer", Toast.LENGTH_SHORT)
                    .show();
        }
        if (keyboardPort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (correctIp && mousePort > 0 && keyboardPort > 0) {
        SharedPreferences.Editor editor = mSettings.edit();
        editor.putString(StartActivity.PREF_SERVER_IP, ip).putInt(StartActivity.PREF_MOUSE_PORT, mousePort)
                .putInt(StartActivity.PREF_KEYBOARD_PORT, keyboardPort);

        editor.commit();
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setTextColor(Color.GREEN);
        tv.setText("Settings saved.");
        tv.setVisibility(View.VISIBLE);
    } else {
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setText("Incorrect input data.");
        tv.setTextColor(Color.RED);
        tv.setVisibility(View.VISIBLE);
    }
}

From source file:au.com.wallaceit.reddinator.SimpleTabsWidget.java

private void insertTab(int index, String text) {

    TabClickListener clickListener = new TabClickListener(index);
    LinearLayout tabContainer = (LinearLayout) inflater.inflate(R.layout.tab, tabWidget, false);
    tabContainer.setOnClickListener(clickListener);

    TextView tabText = (TextView) tabContainer.findViewById(R.id.tab_text);
    tabText.setText(text);/*from  www .jav  a 2 s. c o m*/
    tabText.setTextColor(colors[0]);
    tabItems.add(tabText);

    LinearLayout indicator = (LinearLayout) tabContainer.findViewById(R.id.tab_indicator);
    indicator.setBackgroundColor(colors[1]);
    indicatorItems.add(indicator);

    tabContainer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1));
    tabWidget.addView(tabContainer);
}

From source file:com.axinom.drm.quickstart.activity.SampleChooserActivity.java

private void makeMoviesRequest() {
    JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, API_CATALOG, null,
            new Response.Listener<JSONArray>() {
                @Override/*from   w  w  w. j  a  va  2s.  c  om*/
                public void onResponse(JSONArray response) {
                    // Adding video URLs and names to lists from json array response.
                    for (int i = 0; i < response.length(); i++) {
                        try {
                            JSONObject jsonObject = response.getJSONObject(i);
                            mVideoUrls.add(jsonObject.getString("url"));
                            mVideoNames.add(jsonObject.getString("name"));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    ArrayAdapter adapter = new ArrayAdapter<String>(getApplicationContext(),
                            android.R.layout.simple_list_item_1, mVideoNames) {
                        @Override
                        public View getView(int position, View convertView, ViewGroup parent) {
                            View view = super.getView(position, convertView, parent);
                            TextView textView = (TextView) view.findViewById(android.R.id.text1);
                            textView.setTextColor(Color.BLACK);
                            return view;
                        }
                    };
                    mListView.setAdapter(adapter);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, "Movies json was not loaded with error: " + error.getMessage());
                }
            });
    BaseApp.requestQueue.add(request);
}

From source file:eu.operando.operandoapp.wifi.AccessPointsDetail.java

public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) {

    TextView ssidLabel = (TextView) view.findViewById(R.id.ssid);
    ssidLabel.setText(wiFiDetail.getTitle());
    TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed);
    textLinkSpeed.setTextColor(Color.BLACK);
    String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress();
    boolean isConnected = StringUtils.isNotBlank(ipAddress);
    if (!isConnected) {
        textLinkSpeed.setVisibility(View.GONE);
        ssidLabel.setTextColor(resources.getColor(android.R.color.black));
    } else {/*from ww w . jav  a 2 s  .co m*/
        ssidLabel.setTextColor(resources.getColor(R.color.connected));

        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));
        }
    }

    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(Color.BLACK);
    //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());

    LayoutInflater layoutInflater = mainContext.getLayoutInflater();

    final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig();
    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    if (wiFiApConfig != null) {

        configuredImage.setVisibility(View.VISIBLE);

        if (isOperandoCompatible(wiFiApConfig)) {
            configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light));
            view.setOnClickListener(
                    new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected));
        } else {
            configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light));
            view.setOnClickListener(new ForgetClickListener(context, wiFiDetail));
        }

    } else {
        configuredImage.setVisibility(View.GONE);
        view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater));
    }

}

From source file:android.hawkencompanionapp.fragments.MechGuideFragment.java

private void createFragmentTabs(View v) {
    mTabHost = (FragmentTabHost) v.findViewById(R.id.tabhost);
    mTabHost.setOnTouchListener(this);

    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.tabFrameLayout);
    mTabHost.addTab(mTabHost.newTabSpec(TAB_SPEC_MECH_LIGHT).setIndicator(getString(R.string.mech_tab_light),
            getResources().getDrawable(android.R.drawable.star_on)), LightMechsGuideTab.class, null);
    mTabHost.addTab(mTabHost.newTabSpec(TAB_SPEC_MECH_MEDIUM).setIndicator(getString(R.string.mech_tab_medium),
            getResources().getDrawable(android.R.drawable.star_on)), MediumMechsGuideTab.class, null);
    mTabHost.addTab(mTabHost.newTabSpec(TAB_SPEC_MECH_HEAVY).setIndicator(getString(R.string.mech_tab_heavy),
            getResources().getDrawable(android.R.drawable.star_on)), HeavyMechsGuideTab.class, null);
    mTabHost.setOnTabChangedListener(this);

    //Set the text with each tab to white.
    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
        TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        tv.setTextColor(Color.WHITE);
    }/*from   w w  w  .  j  a  v a  2 s.c om*/
}

From source file:chrisrenke.drawerarrowdrawable.ContentFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    Bundle args = getArguments();/*from  w w  w . j ava  2  s .co m*/

    if (args != null) {
        TextView title = (TextView) view.findViewById(R.id.item_title);
        title.setText("Title: " + args.getCharSequence(KEY_TITLE));

        int indicatorColor = args.getInt(KEY_INDICATOR_COLOR);
        TextView indicatorColorView = (TextView) view.findViewById(R.id.item_indicator_color);
        indicatorColorView.setText("Indicator: #" + Integer.toHexString(indicatorColor));
        indicatorColorView.setTextColor(indicatorColor);

        int dividerColor = args.getInt(KEY_DIVIDER_COLOR);
        TextView dividerColorView = (TextView) view.findViewById(R.id.item_divider_color);
        dividerColorView.setText("Divider: #" + Integer.toHexString(dividerColor));
        dividerColorView.setTextColor(dividerColor);
    }
}