List of usage examples for android.view View setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:net.gsantner.opoc.ui.FilesystemDialog.java
@Override public void onViewCreated(View root, @Nullable Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); Context context = getContext(); if (_buttonCancel == null) { ButterKnife.bind(this, root); if (_buttonCancel == null) { System.err.println("Error: at " + getClass().getName() + " :: Could not bind UI"); }/*from w ww.j a va2s. c om*/ } if (_dopt == null || _buttonCancel == null) { dismiss(); return; } _buttonCancel.setVisibility(_dopt.cancelButtonEnable ? View.VISIBLE : View.GONE); _buttonCancel.setTextColor(rcolor(_dopt.accentColor)); _buttonCancel.setText(_dopt.cancelButtonText); _buttonOk.setVisibility(_dopt.okButtonEnable ? View.VISIBLE : View.GONE); _buttonOk.setTextColor(rcolor(_dopt.accentColor)); _buttonOk.setText(_dopt.okButtonText); _dialogTitle.setTextColor(rcolor(_dopt.titleTextColor)); _dialogTitle.setBackgroundColor(rcolor(_dopt.primaryColor)); _dialogTitle.setText(_dopt.titleText); _dialogTitle.setVisibility(_dopt.titleTextEnable ? View.VISIBLE : View.GONE); _homeButton.setImageResource(_dopt.homeButtonImage); _homeButton.setVisibility(_dopt.homeButtonEnable ? View.VISIBLE : View.GONE); _homeButton.setColorFilter(rcolor(_dopt.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_ATOP); _buttonSearch.setImageResource(_dopt.searchButtonImage); _buttonSearch.setVisibility(_dopt.searchEnable ? View.VISIBLE : View.GONE); _buttonSearch.setColorFilter(rcolor(_dopt.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_ATOP); _searchEdit.setHint(_dopt.searchHint); _searchEdit.setTextColor(rcolor(_dopt.primaryTextColor)); _searchEdit.setHintTextColor(rcolor(_dopt.secondaryTextColor)); root.setBackgroundColor(rcolor(_dopt.backgroundColor)); LinearLayoutManager lam = (LinearLayoutManager) _recyclerList.getLayoutManager(); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getActivity(), lam.getOrientation()); _recyclerList.addItemDecoration(dividerItemDecoration); _filesystemDialogAdapter = new FilesystemDialogAdapter(_dopt, context); _recyclerList.setAdapter(_filesystemDialogAdapter); _filesystemDialogAdapter.getFilter().filter(""); onFsDoUiUpdate(_filesystemDialogAdapter); }
From source file:com.armtimes.fragments.FragmentAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder viewHolder = (ViewHolder) view.getTag(); final String title = cursor.getString(viewHolder.titleIndex); final String description = cursor.getString(viewHolder.shortDescriptionIndex); final int isRead = cursor.getInt(viewHolder.isRead); viewHolder.textViewInfo.setText(Html.fromHtml(String.format("<b>%s</b> %s", title, description))); final String imagePath = cursor.getString(viewHolder.imagePathIndex); if (imagePath != null && !imagePath.isEmpty()) { // Read image from storage. InputStream is = null;/*from w ww. j a v a2 s. co m*/ try { is = new FileInputStream(new File(imagePath)); // Set Bitmap to Image View. viewHolder.imageViewThumbnail.setImageBitmap(BitmapFactory.decodeStream(is)); // Set visibility of Image view to VISIBLE. viewHolder.imageViewThumbnail.setVisibility(View.VISIBLE); // In the case if Image was successfully set to the // image view change layout_weight parameter of image // view to (=2) and layout_width to (=0) in order to // show text and image view in a right way. viewHolder.textViewInfo.setLayoutParams(params2f); } catch (IOException ignore) { viewHolder.textViewInfo.setLayoutParams(params3f); // In the case if exception occurs and image can't be set. // Hide Thumbnail image. viewHolder.imageViewThumbnail.setVisibility(View.GONE); } finally { if (is != null) { try { is.close(); } catch (IOException ignore) { } } } } else { viewHolder.imageViewThumbnail.setVisibility(View.GONE); viewHolder.textViewInfo.setLayoutParams(params3f); } view.setBackgroundColor(isRead != 1 ? Color.parseColor("#EEEEEE") : Color.WHITE); }
From source file:com.dycody.android.idealnote.ListFragment.java
/** * Retrieves from the single listview note item the element to be zoomed when opening a note *///w ww . j a v a2s . c o m private ImageView getZoomListItemView(View view, Note note) { if (expandedImageView != null) { View targetView = null; if (note.getAttachmentsList().size() > 0) { targetView = view.findViewById(R.id.attachmentThumbnail); } if (targetView == null && note.getCategory() != null) { targetView = view.findViewById(R.id.category_marker); } if (targetView == null) { targetView = new ImageView(mainActivity); targetView.setBackgroundColor(Color.WHITE); } targetView.setDrawingCacheEnabled(true); targetView.buildDrawingCache(); Bitmap bmp = targetView.getDrawingCache(); expandedImageView.setBackgroundColor(BitmapUtils.getDominantColor(bmp)); } return expandedImageView; }
From source file:edu.pdx.cecs.orcycle.FragmentSavedNotesSection.java
void populateNoteList(ListView lv) { // Get list from the real phone database. W00t! final DbAdapter mDb = new DbAdapter(getActivity()); //mDb.open(); mDb.openReadOnly();/* w ww . ja v a2s . c o m*/ try { allNotes = mDb.fetchAllNotes(); Log.e(MODULE_TAG, "------------------> populateNoteList()"); String[] from = new String[] { "noteseverity", "noterecorded" }; int[] to = new int[] { R.id.tvSnliNoteSeverity, R.id.tvSnliRecorded }; sna = new SavedNotesAdapter(getActivity(), R.layout.saved_notes_list_item, allNotes, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); lv.setAdapter(sna); } catch (SQLException ex) { Log.e(MODULE_TAG, ex.getMessage()); // Do nothing, for now! } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } mDb.close(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int pos, long noteId) { Log.v(MODULE_TAG, "onItemClick (id = " + String.valueOf(noteId) + ", pos = " + String.valueOf(pos) + ")"); try { if (mActionModeNote == null) { // If the note has just been recently scheduled, we won't ask the user // if they want to upload it. This fixes a bug whereby the note is // in the process of uploading, but the user wants to see it now. if (NoteUploader.isPending(noteId)) { transitionToNoteMapActivity(noteId); } else { final DbAdapter mDb = new DbAdapter(getActivity()); mDb.openReadOnly(); try { int noteStatus = mDb.getNoteStatus(noteId); if (noteStatus == 2) { transitionToNoteMapActivity(noteId); } else if (noteStatus == 1) { buildAlertMessageUnuploadedNoteClicked(noteId); } } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } finally { mDb.close(); } } } else { // highlight if (noteIdArray.indexOf(noteId) > -1) { noteIdArray.remove(noteId); v.setBackgroundColor(Color.parseColor("#80ffffff")); } else { noteIdArray.add(noteId); v.setBackgroundColor(Color.parseColor("#ff33b5e5")); } // Toast.makeText(getActivity(), "Selected: " + noteIdArray, // Toast.LENGTH_SHORT).show(); if (noteIdArray.size() == 0) { saveMenuItemDelete.setEnabled(false); } else { saveMenuItemDelete.setEnabled(true); } mActionModeNote.setTitle(noteIdArray.size() + " Selected"); } } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } } }); registerForContextMenu(lv); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * Called after the dimension of the camera frame is set. The dimensions are necessary to convert * the frame coordinates to view coordinates. * * @param width width of the frame * @param height height of the frame * @param cameraOrientation orientation of the camera *//*from w w w.j a va2s .co m*/ @Override public void onFrameDimensionChange(int width, int height, int cameraOrientation) { mCameraOrientation = cameraOrientation; mCVResult.setFrameDimensions(width, height, cameraOrientation); CameraPaintLayout l = (CameraPaintLayout) findViewById(R.id.camera_paint_layout); if (l != null) l.setFrameDimensions(width, height); View v = findViewById(R.id.camera_controls_layout); if ((v != null) && (!mCameraPreview.isPreviewFitting())) v.setBackgroundColor(getResources().getColor(R.color.control_background_color_transparent)); }
From source file:com.aniruddhc.acemusic.player.BlacklistManagerActivity.BlacklistedArtistsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;/* w ww . j a v a 2 s. c o m*/ if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); final String songBlacklistStatus = c.getString(c.getColumnIndex(DBAccessHelper.BLACKLIST_STATUS)); String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, BlacklistManagerActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. try { if (BlacklistManagerActivity.songIdBlacklistStatusPair.get(songId).equals("TRUE")) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCCFF4444); } else { holder.checkBox.setChecked(false); convertView.setBackgroundColor(0x00000000); } } catch (Exception e) { e.printStackTrace(); } //Set a tag to the row that will attach the artist's name to it. convertView.setTag(R.string.artist, songArtist); holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCCFF4444); AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask(songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask(songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:com.mifos.utils.DataTableUIBuilder.java
public LinearLayout getDataTableLayout(final DataTable dataTable, JsonArray jsonElements, LinearLayout parentLayout, final Context context, final int entityId, DataTableActionListener mListener) { dataTableActionListener = mListener; /**/*from w w w . j a va 2s . co m*/ * Create a Iterator with Json Elements to Iterate over the DataTable * Response. */ Iterator<JsonElement> jsonElementIterator = jsonElements.iterator(); /* * Each Row of the Data Table is Treated as a Table Here. * Creating the First Table for First Row */ tableIndex = 0; while (jsonElementIterator.hasNext()) { TableLayout tableLayout = new TableLayout(context); tableLayout.setPadding(10, 10, 10, 10); final JsonElement jsonElement = jsonElementIterator.next(); /* * Each Entry in a Data Table is Displayed in the * form of a table where each row contains one Key-Value Pair * i.e a Column Name - Column Value from the DataTable */ int rowIndex = 0; while (rowIndex < dataTable.getColumnHeaderData().size()) { TableRow tableRow = new TableRow(context); tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); tableRow.setPadding(10, 10, 10, 10); if (rowIndex % 2 == 0) { tableRow.setBackgroundColor(Color.LTGRAY); } else { tableRow.setBackgroundColor(Color.WHITE); } TextView key = new TextView(context); key.setText(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()); key.setGravity(Gravity.LEFT); TextView value = new TextView(context); value.setGravity(Gravity.RIGHT); if (jsonElement.getAsJsonObject().get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()) .toString().contains("\"")) { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString() .replace("\"", "")); } else { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString()); } tableRow.addView(key, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tableRow.addView(value, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.setMargins(12, 16, 12, 16); tableLayout.addView(tableRow, layoutParams); rowIndex++; } tableLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "Update Row " + tableIndex, Toast.LENGTH_SHORT).show(); } }); tableLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(context, "Deleting Row " + tableIndex, Toast.LENGTH_SHORT).show(); BaseApiManager baseApiManager = new BaseApiManager(); DataManager dataManager = new DataManager(baseApiManager); Observable<GenericResponse> call = dataManager .removeDataTableEntry(dataTable.getRegisteredTableName(), entityId, Integer.parseInt(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(0).getColumnName()) .toString())); Subscription subscription = call.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<GenericResponse>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(GenericResponse genericResponse) { Toast.makeText(context, "Deleted Row " + tableIndex, Toast.LENGTH_SHORT).show(); dataTableActionListener.onRowDeleted(); } }); return true; } }); View v = new View(context); v.setBackgroundColor(ContextCompat.getColor(context, R.color.black)); parentLayout.addView(tableLayout); parentLayout.addView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 5)); Log.i("TABLE INDEX", "" + tableIndex); tableIndex++; } return parentLayout; }
From source file:im.vector.fragments.VectorRoomSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); View listView = view.findViewById(android.R.id.list); if (null != listView) { listView.setPadding(0, 0, 0, 0); }/*from ww w. ja v a2 s . c o m*/ // seems known issue that the preferences screen does not use the activity theme view.setBackgroundColor(ThemeUtils.getColor(getActivity(), R.attr.riot_primary_background_color)); return view; }
From source file:de.azapps.mirakel.main_activity.MainActivity.java
/** * Highlights the given Task// w ww .j a va2 s . co m * * @param currentTask * @param multiselect */ void highlightCurrentTask(final Task currentTask, final boolean multiselect) { if ((getTaskFragment() == null) || (getTasksFragment() == null) || (getTasksFragment().getAdapter() == null) || (currentTask == null)) { return; } Log.v(MainActivity.TAG, "switched to task " + currentTask.getId() + '(' + currentTask.getName() + ')'); final View tmpView = getTasksFragment().getViewForTask(currentTask); final View currentView = (tmpView == null) ? getTasksFragment().getListView().getChildAt(0) : tmpView; if ((currentView != null) && MirakelCommonPreferences.highlightSelected() && !multiselect) { currentView.post(new Runnable() { @Override public void run() { if (MainActivity.this.oldClickedTask != null) { MainActivity.this.oldClickedTask.setSelected(false); MainActivity.this.oldClickedTask.updateBackground(); } currentView.setBackgroundColor( getResources().getColor(MainActivity.this.darkTheme ? R.color.highlighted_text_holo_dark : R.color.highlighted_text_holo_light)); MainActivity.this.oldClickedTask = (TaskSummary) currentView; } }); } }
From source file:it.feio.android.omninotes.DetailFragment.java
/** * Colors tag marker in note's title and content elements *//* w w w.j a v a2 s. c o m*/ private void setTagMarkerColor(Category tag) { String colorsPref = prefs.getString("settings_colors_app", Constants.PREF_COLORS_APP_DEFAULT); // Checking preference if (!"disabled".equals(colorsPref)) { // Choosing target view depending on another preference ArrayList<View> target = new ArrayList<>(); if ("complete".equals(colorsPref)) { target.add(titleWrapperView); target.add(scrollView); } else { target.add(tagMarkerView); } // Coloring the target if (tag != null && tag.getColor() != null) { for (View view : target) { view.setBackgroundColor(Integer.parseInt(tag.getColor())); } } else { for (View view : target) { view.setBackgroundColor(Color.parseColor("#00000000")); } } } }