List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:jp.co.conit.sss.sn.ex2.fragment.MessagesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText(getString(R.string.no_messages)); // EmptyText????INTERNAL_EMPTY_ID??TextView????? // INTERNAL_EMPTY_ID?ListFragment??EmptyText?ID?????????????ListFragment??????? TextView tx = (TextView) getView().findViewById(INTERNAL_EMPTY_ID); int color = getResources().getColor(R.color.settings_text_color); tx.setTextColor(color); getListView().setOnItemClickListener(new OnItemClickListener() { @Override// w w w. ja v a 2 s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PushMessage pm = (PushMessage) parent.getItemAtPosition(position); String userData = pm.getUserData(); Intent activityIntent = new Intent(); if (StringUtil.isEmpty(userData) || userData.equals("null")) { return; } else { if (userData.startsWith("http")) { activityIntent.setAction(Intent.ACTION_VIEW); activityIntent.setData(Uri.parse(userData)); } else { activityIntent.setClass(mParentActivity, UserDataActivity.class); activityIntent.putExtra("option", userData); } } startActivity(activityIntent); } }); obtainMessagesAsync(); }
From source file:com.ushahidi.android.presentation.view.ui.fragment.MapPostFragment.java
/** * Change Snackbar text color to orange by finding the TextView associated with * it. A bit of a hack to get this working as it doesn't come with a native API for doing this. *//*from ww w . ja v a 2 s . c om*/ private void setSnackbarTextColor() { View view = mSnackbar.getView(); TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(getAppContext().getResources().getColor(R.color.orange)); mSnackbar.show(); }
From source file:br.comoferta.ui.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w .j a va 2 s . c o m */ protected TextView createDefaultTabView(Context context) { ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_selected }, new int[] { -android.R.attr.state_selected }, }, new int[] { Color.WHITE, Color.LTGRAY }); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTextColor(colorStateList); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.frostwire.android.gui.adapters.SearchResultListAdapter.java
private void maybeMarkTitleOpened(View view, SearchResult sr) { int clickedColor = getContext().getResources().getColor(R.color.my_files_listview_item_inactive_foreground); int unclickedColor = getContext().getResources().getColor(R.color.app_text_primary); TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title); title.setTextColor(LocalSearchEngine.instance().hasBeenOpened(sr) ? clickedColor : unclickedColor); }
From source file:com.alexive.graphicalutils.view.CardBuilder.java
private void setTextColor(List<TextView> views, int primaryColor, int secondaryColor) { boolean primary; for (TextView tv : views) { primary = tv.getTag() != null || tv instanceof Button; tv.setTextColor(primary ? primaryColor : secondaryColor); }// www . j ava 2s. c om }
From source file:com.al70b.core.extended_widgets.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;/*from w ww.jav a 2 s . co m*/ } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure we obey the offset targetScrollX -= mTitleOffset; } scrollTo(targetScrollX, 0); // Handle tabs coloring if (selectedChild instanceof TextView) { TextView prev = (TextView) mTabStrip.getChildAt(mTabStrip.getPreviousPosition()); if (!prev.equals(selectedChild)) prev.setTextColor(getResources().getColor(android.R.color.darker_gray)); ((TextView) selectedChild).setTextColor(getResources().getColor(R.color.white)); } else if (selectedChild instanceof LinearLayout) { return; } } }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);/*from ww w .j a v a 2 s .com*/ RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(imageParams); // imageView.setAdjustViewBounds(true); Resources r = context.getResources(); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); TextView descriptionView = new TextView(context); descriptionView.setId(2); descriptionView.setPadding(padding, 0, padding, padding); descriptionView.setText(description); descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10)); descriptionView.setTextColor(Color.WHITE); RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId()); carouselView.addView(descriptionView, descParams); TextView titleView = new TextView(context); titleView.setText(title); titleView.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId()); titleView.setLayoutParams(titleParams); titleView.setTextColor(Color.WHITE); titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0)); titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); carouselView.addView(titleView); }
From source file:samsungsami.io.example.samiremotecontrol.DeviceActivity.java
/** * Fill the device status and info table *//* ww w. ja v a 2 s. c om*/ void fillTable() { TableRow row; TextView t1, t2, t3; for (int current = 0; current < fields.size(); current++) { row = new TableRow(this); t1 = new TextView(this); t1.setTextColor(Color.GRAY); t2 = new TextView(this); t2.setTextColor(Color.BLACK); t3 = new TextView(this); t3.setTextColor(Color.BLACK); t1.setText(fields.get(current)); t2.setText(values.get(current)); t3.setText(units.get(current)); t1.setTextSize(15); t2.setTextSize(15); t3.setTextSize(15); row.addView(t1); if (fields.get(current).equals("state")) { Switch toggle = new Switch(this); toggle.setChecked(values.get(current).toLowerCase().equals("on")); toggle.setEnabled(false); row.addView(toggle); } else row.addView(t2); row.addView(t3); propertiesTableLayout.addView(row, new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // Adjust the view propertiesTableLayout.setColumnStretchable(0, true); propertiesTableLayout.setColumnStretchable(1, true); propertiesTableLayout.setColumnStretchable(2, true); } }
From source file:cc.metapro.openct.customviews.DuringDialog.java
private void setViews(GridLayout gridLayout) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 6; j++) { final int week = i * 6 + j + 1; final TextView textView = new TextView(getActivity()); textView.setText(week + gridLayout.getContext().getString(R.string.week)); textView.setGravity(Gravity.CENTER); if (DURING[week]) { textView.setBackground(/* w w w. j a v a 2 s. co m*/ ContextCompat.getDrawable(getActivity(), R.drawable.text_view_card_style_blue)); textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } else { textView.setBackground( ContextCompat.getDrawable(getActivity(), R.drawable.text_view_card_style_grey)); textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.material_grey)); } textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DURING[week] = !DURING[week]; } }); GridLayout.Spec row = GridLayout.spec(i, 1, 1); GridLayout.Spec col = GridLayout.spec(j, 1, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(row, col); gridLayout.addView(textView, params); selections[i][j] = textView; } } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * ???.//from w w w. j a v a 2 s. co m * * @param index the index */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectedColor); tv.setSelected(true); } } //? int itemWidth = mWidth / tabItemList.size(); LayoutParams mParams = new LayoutParams(itemWidth, tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); AbLogUtil.d(AbSlidingSmoothFixTabView.class, "old--startX:" + startX); int toX = itemWidth * index; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; mSelectedTabIndex = index; }