List of usage examples for android.widget TextView setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.sentaroh.android.Utilities.ContextMenu.CustomContextMenuFragment.java
private void initViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "initViewWidget"); // CommonDialog.setDlgBoxSizeCompact(mDialog); LinearLayout dlg_ll = new LinearLayout(getActivity()); dlg_ll.setOrientation(LinearLayout.VERTICAL); TextView dlg_tv = new TextView(getActivity()); dlg_tv.setBackgroundColor(Color.WHITE); dlg_tv.setTextColor(Color.BLACK); // dlg_tv.setTextSize(32); dlg_tv.setGravity(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.CENTER_HORIZONTAL); ListView dlg_lv = new ListView(getActivity()); dlg_lv.setBackgroundColor(Color.WHITE); dlg_ll.addView(dlg_tv);/*from w w w .j a v a2 s .c om*/ dlg_ll.addView(dlg_lv); mDialog.setContentView(dlg_ll); if (mDialogTitle.length() != 0) { dlg_tv.setText(mDialogTitle); dlg_tv.setVisibility(TextView.VISIBLE); } else dlg_tv.setVisibility(TextView.GONE); dlg_lv.setAdapter(mMenuAdapter); dlg_lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> items, View view, int idx, long id) { CustomContextMenuItem item = (CustomContextMenuItem) mMenuAdapter.getItem(idx); if (item.menu_enabled) { if (idx < mClickHandler.size()) { mClickHandler.get(idx).onClick(item.text); } mFragment.dismiss(); } } }); dlg_lv.setScrollingCacheEnabled(false); dlg_lv.setScrollbarFadingEnabled(false); // int[] colors = {0, 0xFFFF0000, 0}; // red for the example // lv.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); dlg_lv.setDividerHeight(0); }
From source file:org.smap.smapTask.android.activities.TaskAddressActivity.java
/** Called when the activity is first created. */ @Override//from w w w . j a v a 2 s . com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.task_address); // Get the id of the selected list item Bundle bundle = getIntent().getExtras(); taskEntry = Utilities.getTaskWithId(bundle.getLong("id")); try { //String assignment_status = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS)); //String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE)); //String taskAddress = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS)); // Formatting LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textLayout.setMargins(1, 1, 1, 1); TableRow.LayoutParams trLayout = new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); trLayout.setMargins(1, 1, 1, 1); TableLayout tableLayout = (TableLayout) findViewById(R.id.task_address_values); // Add Title TextView title = (TextView) findViewById(R.id.task_title); title.setText(taskEntry.name); // Add Status TableRow r = new TableRow(this); r.setLayoutParams(trLayout); r.setBackgroundColor(0xff0000); TextView text1 = new TextView(this); text1.setText("Status"); text1.setBackgroundColor(0xff0000); TextView text2 = new TextView(this); text2.setText(taskEntry.taskStatus); text2.setBackgroundColor(0xff0000); r.addView(text1); r.addView(text2); tableLayout.addView(r); // Put the Address items in the table Type type = new TypeToken<ArrayList<Address>>() { }.getType(); ArrayList<Address> aArray = new Gson().fromJson(taskEntry.taskAddress, type); if (aArray != null) { for (int i = 0; i < aArray.size(); i++) { r = new TableRow(this); r.setLayoutParams(trLayout); r.setBackgroundColor(0xff0000); text1 = new TextView(this); text1.setText(aArray.get(i).name); text1.setBackgroundColor(0xff0000); text2 = new TextView(this); text2.setText(aArray.get(i).value); text2.setBackgroundColor(0xff0000); r.addView(text1); r.addView(text2); tableLayout.addView(r); } } // Create the buttons LinearLayout buttons = (LinearLayout) findViewById(R.id.task_address_buttons); //menu.setHeaderTitle(taskTitle); if (Utilities.canReject(taskEntry.taskStatus)) { Button b = new Button(this); b.setText("Reject Task"); b.setId(R.id.reject_button); b.setOnClickListener(this); buttons.addView(b); } if (Utilities.canComplete(taskEntry.taskStatus)) { Button b = new Button(this); b.setText("Complete Task"); b.setId(R.id.complete_button); b.setOnClickListener(this); buttons.addView(b); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.weekcalendar.WeekFragment.java
private void setSelectedDateBackground(TextView selectedDateTv) { if (mSelectorDateIndicatorValue != 0) { for (TextView tv : mTextViewArray) { tv.setBackgroundColor(Color.TRANSPARENT); }/* w w w . j a va 2s . co m*/ selectedDateTv.setBackgroundResource(mSelectorDateIndicatorValue); } if (mSelectorHighlightColor != -1) { for (TextView tv : mTextViewArray) { tv.setTextColor(mPrimaryTextColor); } if (mCurrentDateIndex > -1) { mTextViewArray[mCurrentDateIndex].setTextColor(mCurrentDateIndicatorValue); } selectedDateTv.setTextColor(mSelectorHighlightColor); } }
From source file:com.team3.classical.slidingtabs.SlidingTabsBasicFragment.java
void setNoClass(LinearLayout ll, int classes, int color) { TextView blank = new TextView(ll.getContext()); if (color == 0) blank.setMinHeight(dip2px(ll.getContext(), classes * 25)); blank.setBackgroundColor(Color.parseColor("#F0FFFF")); ll.addView(blank);/*from ww w. j a va2 s.co m*/ }
From source file:com.example.SmartBoard.MyActivity.java
/** * Called when the activity is first created. *///from w ww . j a v a 2s . c om @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); handler.usersAdapter = new UserListArrayAdapter(this, R.layout.online_list_message, handler.usersListHistory); listView = (ListView) findViewById(R.id.usersListView); getActionBar().setDisplayHomeAsUpEnabled(false); //disables up navigation TextView header = new TextView(this); header.setBackgroundColor(Color.parseColor("#FFF5EE")); header.setText("Designers:"); header.setTypeface(null, Typeface.BOLD_ITALIC); header.setText(Html.fromHtml("<font color ='black'>D</font>" + "<font color ='blue'>e</font>" + "<font color = 'black'>s</font>" + "<font color ='red'>i</font>" + "<font color = 'black'>g</font>" + "<font color ='magenta'>n</font>" + "<font color = 'black'>e</font>" + "<font color ='blue'>r</font>" + "<font color = 'black'>s</font>" + "<font color = 'black'>:</font>" )); listView.addHeaderView(header, "Online", false); listView.setAdapter(handler.usersAdapter); // handler.registerResources(getApplicationContext()); drawer = (DrawingView) findViewById(R.id.drawing); handler.passDrawingContext(this); }
From source file:com.softminds.matrixcalculator.base_fragments.ViewMatrixFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int index = getArguments().getInt("INDEX"); View v = inflater.inflate(R.layout.view_matrix_frag, container, false); CardView cardView = v.findViewById(R.id.DynamicCardView); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4"); String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd"); cardView.setCardElevation(Integer.parseInt(string)); final int border = getResources().getDimensionPixelOffset(R.dimen.border_width); CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cardView.setUseCompatPadding(true);/*ww w . j ava2s. co m*/ GridLayout gridLayout = new GridLayout(getContext()); int rows = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).getNumberOfRows(); int cols = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).getNumberOfCols(); gridLayout.setRowCount(rows); gridLayout.setColumnCount(cols); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setBackgroundColor(Color.parseColor(string2)); textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()) .GetCompleteList().get(index).getElementOf(i, j)), getLength())); textView.setWidth(CalculatedWidth(cols)); textView.setTextSize(SizeReturner(rows, cols, PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); textView.setHeight(CalculatedHeight(rows)); GridLayout.Spec Row = GridLayout.spec(i, 1); GridLayout.Spec Col = GridLayout.spec(j, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col); params.leftMargin = params.topMargin = params.bottomMargin = params.rightMargin = border; gridLayout.addView(textView, params); } } gridLayout.setLayoutParams(params1); cardView.addView(gridLayout); // Inflate the layout for this fragment return v; }
From source file:org.cvasilak.jboss.mobile.app.fragments.JVMMetricsViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); bar.setTitle(getString(R.string.jvm)); MergeAdapter adapter = new MergeAdapter(); TextView sectionHeader; // Section: Operating System Information sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText("Operating System"); adapter.addView(sectionHeader);/*from w w w. j a v a2 s. co m*/ MetricsAdapter osMetricsAdapter = new MetricsAdapter(getActivity(), osMetrics); adapter.addAdapter(osMetricsAdapter); // Section: Heap Usage sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText("Heap Usage"); adapter.addView(sectionHeader); MetricsAdapter heapMetricsAdapter = new MetricsAdapter(getActivity(), heapMetrics); adapter.addAdapter(heapMetricsAdapter); // Section: Non Heap Usage sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText("Non Heap Usage"); adapter.addView(sectionHeader); MetricsAdapter nonHeapMetricsAdapter = new MetricsAdapter(getActivity(), nonHeapMetrics); adapter.addAdapter(nonHeapMetricsAdapter); // Section: Thread Usage sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText("Thread Usage"); adapter.addView(sectionHeader); MetricsAdapter threadUsageMetricsAdapter = new MetricsAdapter(getActivity(), threadUsageMetrics); adapter.addAdapter(threadUsageMetricsAdapter); setListAdapter(adapter); }
From source file:com.starshow.app.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 ww . j a v a 2 s. co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setBackgroundColor(getResources().getColor(R.color.white)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); 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); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);// w ww . jav a 2 s. c om 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:fr.cph.chicago.adapter.SearchAdapter.java
@Override public final View getView(final int position, View convertView, final ViewGroup parent) { LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_search, null); TextView rounteName = (TextView) convertView.findViewById(R.id.station_name); if (position < mTrains.size()) { final Station station = (Station) getItem(position); Set<TrainLine> lines = station.getLines(); rounteName.setText(station.getName()); LinearLayout stationColorView = (LinearLayout) convertView.findViewById(R.id.station_color); int indice = 0; for (TrainLine tl : lines) { TextView textView = new TextView(mContext); textView.setBackgroundColor(tl.getColor()); textView.setText(" "); textView.setTextSize(mContext.getResources().getDimension(R.dimen.activity_list_station_colors)); stationColorView.addView(textView); if (indice != lines.size()) { textView = new TextView(mContext); textView.setText(""); textView.setPadding(0, 0, (int) mContext.getResources().getDimension(R.dimen.activity_list_station_colors_space), 0);/*from w ww. jav a 2 s . c o m*/ textView.setTextSize( mContext.getResources().getDimension(R.dimen.activity_list_station_colors)); stationColorView.addView(textView); } indice++; } convertView.setOnClickListener( new FavoritesTrainOnClickListener(mActivity, mContainer, station.getId(), lines)); } else if (position < mTrains.size() + mBuses.size()) { final BusRoute busRoute = (BusRoute) getItem(position); TextView type = (TextView) convertView.findViewById(R.id.train_bus_type); type.setText("B"); rounteName.setText(busRoute.getId() + " " + busRoute.getName()); final TextView loadingTextView = (TextView) convertView.findViewById(R.id.loading_text_view); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadingTextView.setVisibility(LinearLayout.VISIBLE); mActivity.startRefreshAnimation(); new DirectionAsyncTask().execute(busRoute, loadingTextView); } }); } else { final BikeStation bikeStation = (BikeStation) getItem(position); TextView type = (TextView) convertView.findViewById(R.id.train_bus_type); type.setText("D"); rounteName.setText(bikeStation.getName()); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ChicagoTracker.getAppContext(), BikeStationActivity.class); Bundle extras = new Bundle(); extras.putParcelable("station", bikeStation); intent.putExtras(extras); mActivity.startActivity(intent); mActivity.overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }); } return convertView; }