List of usage examples for android.widget TextView setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.example.android.rowanparkingpass.Activities.PassActivity.java
public void setVehicleView() { View vehicleView = findViewById(R.id.vehicle_view); vehicleView.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j ava 2s. c o m*/ public void onClick(View v) { Intent intent = new Intent(PassActivity.this, VehiclesActivity.class); intent.putExtra(MODE, mode.UPDATE_PASS_VEHICLE.name()); intent.putExtra("Driver", (Serializable) driver); startActivity(intent); finish(); } }); vehicleView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(PassActivity.this, CreateVehicleActivity.class); intent.putExtra(MODE, mode.UPDATE_PASS_VEHICLE.name()); intent.putExtra("Driver", (Serializable) driver); intent.putExtra("Vehicle", (Serializable) vehicle); startActivity(intent); finish(); return true; } }); // Set up text views for vehicle info TextView newVehicle = (TextView) findViewById(R.id.new_vehicle_text_view); TextView carText = (TextView) findViewById(R.id.car_text_view); TextView plateText = (TextView) findViewById(R.id.plate_text_view); TextView carColor = (TextView) findViewById(R.id.car_color); newVehicle.setText(""); carText.setText(vehicle.getYear() + " " + vehicle.getMake() + " " + vehicle.getModel()); plateText.setText(vehicle.getVehicleState() + " " + vehicle.getLicensePlate()); carColor.setText(""); carColor.setTextColor(Integer.parseInt(vehicle.getColor())); carColor.setBackgroundColor(Integer.parseInt(vehicle.getColor())); }
From source file:com.rachelgrau.rachel.health4theworldstroke.Activities.InfoActivity.java
public void addSubheaderWithText(String text) { LinearLayout ll = (LinearLayout) findViewById(R.id.text_linear_layout); TextView textView = new TextView(this); textView.setTypeface(null, Typeface.BOLD); textView.setText(text);/*from ww w . java 2s . c o m*/ textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setPadding(40, 10, 40, 0); textView.setTextSize(16); textView.setBackgroundColor(Color.WHITE); ll.addView(textView); }
From source file:fr.cph.chicago.activity.StationActivity.java
@SuppressWarnings("unchecked") @Override/* ww w .jav a 2 s .c om*/ protected final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChicagoTracker.checkTrainData(this); if (!this.isFinishing()) { // Load data DataHolder dataHolder = DataHolder.getInstance(); this.mTrainData = dataHolder.getTrainData(); mIds = new HashMap<String, Integer>(); // Load right xml setContentView(R.layout.activity_station); // Get station id from bundle extra if (mStationId == null) { mStationId = getIntent().getExtras().getInt("stationId"); } // Get station from station id mStation = mTrainData.getStation(mStationId); MultiMap<String, String> reqParams = new MultiValueMap<String, String>(); reqParams.put("mapid", String.valueOf(mStation.getId())); new LoadData().execute(reqParams); // Call google street api to load image new DisplayGoogleStreetPicture().execute(mStation.getStops().get(0).getPosition()); this.mIsFavorite = isFavorite(); TextView textView = (TextView) findViewById(R.id.activity_bike_station_station_name); textView.setText(mStation.getName().toString()); mStreetViewImage = (ImageView) findViewById(R.id.activity_bike_station_streetview_image); mStreetViewText = (TextView) findViewById(R.id.activity_bike_station_steetview_text); mMapImage = (ImageView) findViewById(R.id.activity_bike_station_map_image); mDirectionImage = (ImageView) findViewById(R.id.activity_bike_station_map_direction); mFavoritesImage = (ImageView) findViewById(R.id.activity_bike_station_favorite_star); if (mIsFavorite) { mFavoritesImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_save_active)); } mFavoritesImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StationActivity.this.switchFavorite(); } }); LinearLayout stopsView = (LinearLayout) findViewById(R.id.activity_bike_station_details); this.mParamsStop = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); Map<TrainLine, List<Stop>> stops = mStation.getStopByLines(); CheckBox checkBox = null; for (Entry<TrainLine, List<Stop>> e : stops.entrySet()) { final TrainLine line = e.getKey(); List<Stop> stopss = e.getValue(); Collections.sort(stopss); LayoutInflater layoutInflater = (LayoutInflater) ChicagoTracker.getAppContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.activity_station_line_title, null); TextView lineTextView = (TextView) view.findViewById(R.id.activity_bus_station_value); lineTextView.setText(line.toStringWithLine()); TextView lineColorTextView = (TextView) view.findViewById(R.id.activity_bus_color); lineColorTextView.setBackgroundColor(line.getColor()); stopsView.addView(view); for (final Stop stop : stopss) { LinearLayout line2 = new LinearLayout(this); line2.setOrientation(LinearLayout.HORIZONTAL); line2.setLayoutParams(mParamsStop); checkBox = new CheckBox(this); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Preferences.saveTrainFilter(mStationId, line, stop.getDirection(), isChecked); } }); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Update timing MultiMap<String, String> reqParams = new MultiValueMap<String, String>(); reqParams.put("mapid", String.valueOf(mStation.getId())); new LoadData().execute(reqParams); } }); checkBox.setChecked(Preferences.getTrainFilter(mStationId, line, stop.getDirection())); checkBox.setText(stop.getDirection().toString()); checkBox.setTextColor(getResources().getColor(R.color.grey)); line2.addView(checkBox); stopsView.addView(line2); LinearLayout line3 = new LinearLayout(this); line3.setOrientation(LinearLayout.VERTICAL); line3.setLayoutParams(mParamsStop); int id3 = Util.generateViewId(); line3.setId(id3); mIds.put(line.toString() + "_" + stop.getDirection().toString(), id3); stopsView.addView(line3); } } getActionBar().setDisplayHomeAsUpEnabled(true); Util.trackScreen(this, R.string.analytics_train_details); } }
From source file:com.gh4a.activities.IssueEditActivity.java
private void setLabelSelection(TextView view, boolean selected) { Label label = (Label) view.getTag(); if (selected) { int color = ApiHelpers.colorForLabel(label); view.setTypeface(view.getTypeface(), Typeface.BOLD); view.setBackgroundColor(color); view.setTextColor(UiUtils.textColorForBackground(this, color)); } else {// ww w . ja v a2s . c o m view.setTypeface(view.getTypeface(), 0); view.setBackgroundColor(0); view.setTextColor(ContextCompat.getColor(this, Gh4Application.THEME != R.style.LightTheme ? R.color.label_fg_light : R.color.label_fg_dark)); } }
From source file:com.gh4a.IssueLabelListActivity.java
private void selectLabel(TextView tvLabel, View viewColor, String color, boolean clearOtherSelected, EditText etLabel) {/*from www .ja v a 2s . c o m*/ final Typeface boldCondensed = getApplicationContext().boldCondensed; tvLabel.setTag(color); viewColor.setBackgroundColor(Color.parseColor("#" + color)); tvLabel.setBackgroundColor(Color.parseColor("#" + color)); int r = Color.red(Color.parseColor("#" + color)); int g = Color.green(Color.parseColor("#" + color)); int b = Color.blue(Color.parseColor("#" + color)); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } tvLabel.setTypeface(boldCondensed); mSelectedColor = color; mSelectedEtLabel = etLabel; mSelectedLabel = tvLabel.getText().toString(); if (clearOtherSelected) { clearOtherSelected(false); } }
From source file:com.zhongsou.souyue.ui.indicator.SuberPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from www. j a va 2s.c o m mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final TextView child = (TextView) mTabLayout.getChildAt(i); final boolean isSelected = (i == item); if (isSelected) { //?. child.setTextColor(Color.parseColor("#da4644")); child.setBackgroundResource(R.drawable.suberlist_indicator_underline); } else { //????? child.setTextColor(getResources().getColor(R.color.middark_black)); child.setBackgroundColor(Color.TRANSPARENT); } child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } }
From source file:com.google.adsensequickstart.DisplayReportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); sv.addView(tl);/*from w w w . j av a 2 s . c o m*/ if (displayReportController == null) { return sv; } AdsenseReportsGenerateResponse response = displayReportController.getReportResponse(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(10, 10, 10, 10); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tvParams.setMargins(10, 10, 10, 10); List<Headers> headers = response.getHeaders(); TableRow tr = new TableRow(getActivity()); tl.addView(tr); for (Headers header : headers) { TextView tv = new TextView(getActivity()); tv.setText(header.getName()); tr.setLayoutParams(tableRowParams); tr.addView(tv); } if (response.getRows() != null && !response.getRows().isEmpty()) { for (List<String> row : response.getRows()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); for (String cell : row) { TextView tv = new TextView(getActivity()); tv.setText(cell); trow.addView(tv); tv.setLayoutParams(tvParams); tv.setPadding(15, 5, 15, 5); tv.setBackgroundColor(Color.WHITE); } } } return sv; }
From source file:utils.widget.vpi_lib.TabPageIndicator_Custom.java
@SuppressLint("InflateParams") private void addTab(int index, CharSequence text, int iconResId, String url) { // TODO//from w w w . ja v a 2s . c om final TabView tabView = new TabView(getContext()); tabView.mIndex = index; LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setTag(index); linearLayout.setFocusable(true); linearLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { LinearLayout tabView = (LinearLayout) v; final int oldSelected = mViewPager.getCurrentItem(); final int newSelected = Integer.valueOf(tabView.getTag().toString()); mViewPager.setCurrentItem(newSelected); if (oldSelected == newSelected && mTabReselectedListener != null) { mTabReselectedListener.onTabReselected(newSelected); } } }); parentView = LayoutInflater.from(getContext()).inflate(R.layout.vpi_tap_custom, null); ImageView img = (ImageView) parentView.findViewById(R.id.tabImage); // img.setImageResource(iconResId); /* * ProgressBar pbBar = (ProgressBar) * view.findViewById(R.id.progressBar_tab_custom); */ // LinearLayout layout = (LinearLayout) // view.findViewById(R.id.vpi_custom_layout); TextView txtTitle = (TextView) parentView.findViewById(R.id.vpi_custom_txt_Title); TextView txtBottom = (TextView) parentView.findViewById(R.id.vpi_custom_txt_btm); // TODO // LinearLayout.LayoutParams layoutParams = new // LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); // layout.setLayoutParams(layoutParams); txtTitle.setText(text); txtTitle.setTextColor(getResources().getColor(R.color.vpi_non_focus)); txtBottom.setBackgroundColor(getResources().getColor(R.color.vpi_non_focus)); /* * AQuery aq = new AQuery(getContext()); * aq.id(img).progress(pbBar).image(url, false, true, 0, * R.drawable.img_default_category, new BitmapAjaxCallback() { * * @SuppressLint("NewApi") @SuppressWarnings("deprecation") * * @Override protected void callback(String url, ImageView iv, Bitmap * bm, AjaxStatus status) { int sdk = android.os.Build.VERSION.SDK_INT; * if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { * iv.setBackgroundDrawable(new * BitmapDrawable(getContext().getResources(), bm)); } else { * iv.setBackground(new BitmapDrawable(getContext().getResources(), * bm)); } } }); */ linearLayout.addView(parentView); linearLayout.addView(tabView); mTabLayout.addView(linearLayout, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 1)); }
From source file:com.farmerbb.taskbar.service.DashboardService.java
@SuppressLint("RtlHardcoded") private void drawDashboard() { windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT);/* w w w. java2 s .c o m*/ // Initialize views layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.setVisibility(View.GONE); layout.setAlpha(0); SharedPreferences pref = U.getSharedPreferences(this); int width = pref.getInt("dashboard_width", getApplicationContext().getResources().getInteger(R.integer.dashboard_width)); int height = pref.getInt("dashboard_height", getApplicationContext().getResources().getInteger(R.integer.dashboard_height)); boolean isPortrait = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isLandscape = getApplicationContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; if (isPortrait) { columns = height; rows = width; } if (isLandscape) { columns = width; rows = height; } maxSize = columns * rows; int backgroundTint = U.getBackgroundTint(this); int accentColor = U.getAccentColor(this); int accentColorAlt = accentColor; accentColorAlt = ColorUtils.setAlphaComponent(accentColorAlt, Color.alpha(accentColorAlt) / 2); int cellCount = 0; for (int i = 0; i < columns; i++) { LinearLayout layout2 = new LinearLayout(this); layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); layout2.setOrientation(LinearLayout.VERTICAL); for (int j = 0; j < rows; j++) { DashboardCell cellLayout = (DashboardCell) View.inflate(this, R.layout.dashboard, null); cellLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1)); cellLayout.setBackgroundColor(backgroundTint); cellLayout.setOnClickListener(cellOcl); cellLayout.setOnHoverListener(cellOhl); TextView empty = (TextView) cellLayout.findViewById(R.id.empty); empty.setBackgroundColor(accentColorAlt); empty.setTextColor(accentColor); Bundle bundle = new Bundle(); bundle.putInt("cellId", cellCount); cellLayout.setTag(bundle); cells.put(cellCount, cellLayout); cellCount++; layout2.addView(cellLayout); } layout.addView(layout2); } mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); for (int i = 0; i < maxSize; i++) { int appWidgetId = pref.getInt("dashboard_widget_" + Integer.toString(i), -1); if (appWidgetId != -1) addWidget(appWidgetId, i, false); else if (pref.getBoolean("dashboard_widget_" + Integer.toString(i) + "_placeholder", false)) addPlaceholder(i); } mAppWidgetHost.stopListening(); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(addWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(removeWidgetReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_DASHBOARD")); LocalBroadcastManager.getInstance(this).registerReceiver(addWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.ADD_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(removeWidgetReceiver, new IntentFilter("com.farmerbb.taskbar.REMOVE_WIDGET_COMPLETED")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_DASHBOARD")); windowManager.addView(layout, params); new Handler().postDelayed(() -> { int paddingSize = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(DashboardService.this)) { case "top_vertical_left": case "bottom_vertical_left": layout.setPadding(paddingSize, 0, 0, 0); break; case "top_left": case "top_right": layout.setPadding(0, paddingSize, 0, 0); break; case "top_vertical_right": case "bottom_vertical_right": layout.setPadding(0, 0, paddingSize, 0); break; case "bottom_left": case "bottom_right": layout.setPadding(0, 0, 0, paddingSize); break; } }, 100); }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentOverzicht.java
/** * Populate the koopman fragment item details item when the loader has finished * @param loader the cursor loader//from w ww . j a v a 2 s.c o m * @param data data object containing one or more koopman rows with joined sollicitatie data */ @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // get the markt id from the sharedprefs SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0); // koopman photo Glide.with(getContext()) .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL))) .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage); // koopman naam String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " " + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM)); mKoopmanVoorlettersAchternaamText.setText(naam); // koopman erkenningsnummer String erkenningsnummer = data .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER)); mErkenningsnummerText.setText(erkenningsnummer); // koopman sollicitaties View view = getView(); if (view != null) { LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder); placeholderLayout.removeAllViews(); // add multiple markt sollicitatie views to the koopman items while (!data.isAfterLast()) { // inflate sollicitatie layout and populate its view items View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie, null); // highlight the sollicitatie for the current markt if (data.getCount() > 1 && marktId > 0 && marktId == data .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) { childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); } // markt afkorting String marktAfkorting = data .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING)); TextView marktAfkortingText = (TextView) childLayout .findViewById(R.id.sollicitatie_markt_afkorting); marktAfkortingText.setText(marktAfkorting); // koopman sollicitatienummer String sollicitatienummer = data.getString( data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER)); TextView sollicitatienummerText = (TextView) childLayout .findViewById(R.id.sollicitatie_sollicitatie_nummer); sollicitatienummerText.setText(sollicitatienummer); // koopman sollicitatie status String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status")); TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status); sollicitatieStatusText.setText(sollicitatieStatus); if (sollicitatieStatus != null && !sollicitatieStatus.equals("?") && !sollicitatieStatus.equals("")) { sollicitatieStatusText .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(), Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus))); } // add view and move cursor to next placeholderLayout.addView(childLayout, data.getPosition()); data.moveToNext(); } } } }