List of usage examples for android.view View setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.daxstudio.sa.base.android.BaseDialogFragment.java
@Override public void onStart() { super.onStart(); // Less dimmed background; see http://stackoverflow.com/q/13822842/56285 final Window window = getDialog().getWindow(); final WindowManager.LayoutParams params = window.getAttributes(); params.dimAmount = getDimAmount(); // dim only a little bit window.setAttributes(params);//from ww w . jav a2 s. c om window.setLayout(getWidth(), getHeight()); window.setGravity(getGravity()); // Transparent background; see http://stackoverflow.com/q/15007272/56285 // (Needed to make dialog's alpha shadow look good) window.setBackgroundDrawableResource(android.R.color.transparent); final Resources res = getResources(); final int titleDividerId = res.getIdentifier("titleDivider", "id", "android"); if (titleDividerId > 0) { final View titleDivider = getDialog().findViewById(titleDividerId); if (titleDivider != null) { titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent)); } } }
From source file:com.example.android.tourguide.CategoryAdaptor.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }//from w ww .j a v a2 s. c o m // Get the {@link Category} object located at this position in the list Category currentCategory = getItem(position); // Find the TextView in the list_item.xml layout with the ID category_view. TextView categoryView = (TextView) listItemView.findViewById(R.id.catergory_view); // Get the Category from the currentCategry object and set this text on // the Category TextView. categoryView.setText(currentCategory.getCategory()); // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that resource ID maps int color = ContextCompat.getColor(getContext(), mColorResourceID); // Set the background color of the text container view textContainer.setBackgroundColor(color); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); if (currentCategory.hasImage()) { // Set the image view to the image resource specified in the current word. imageView.setImageResource(currentCategory.getImageResourceId()); // Find the color that resource ID maps imageView.setBackgroundColor(color); // Make sure the view is Visible imageView.setVisibility(View.VISIBLE); } else { imageView.setVisibility(View.GONE); } // Return the whole list item layout so that it can be shown in // the ListView. return listItemView; }
From source file:com.cw.litenote.operation.import_export.Import_filesList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.import_sd_files_list, container, false); View view = rootView.findViewById(R.id.view_back_btn_bg); view.setBackgroundColor(ColorSet.getBarColor(getActivity())); // back button Button backButton = (Button) rootView.findViewById(R.id.view_back); backButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_back, 0, 0, 0); // update button Button renewButton = (Button) rootView.findViewById(R.id.view_renew); renewButton.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_popup_sync, 0, 0, 0); // do cancel// w w w . j a v a2s. c om backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { getActivity().getSupportFragmentManager().popBackStack(); } }); // do update renewButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // source dir: Download String srcDirName = "Download";//todo Could be empty String srcDirPath = Environment.getExternalStorageDirectory().toString() + "/" + srcDirName; System.out.println("srcDirPath = " + srcDirPath); /** * Note about getExternalStorageDirectory: * don't be confused by the word "external" here. * This directory can better be thought as media/shared storage. * It is a filesystem that can hold a relatively large amount of data and * that is shared across all applications (does not enforce permissions). * Traditionally this is an SD card, but it may also be implemented as built-in storage in a device * that is distinct from the protected internal storage and can be mounted as a filesystem on a computer. */ // target dir String targetDirPath = Environment.getExternalStorageDirectory().toString() + "/" + Util.getStorageDirName(getActivity()); // copy source files to target directory File srcDir = new File(srcDirPath); if (srcDir.exists()) { for (File srcFile : srcDir.listFiles()) { File targetFile = new File(targetDirPath + "/" + srcFile.getName()); System.out.println("targetFile.getName() = " + targetFile.getName()); try { if (srcFile.getName().contains("XML") || srcFile.getName().contains("xml")) FileUtils.copyFile(srcFile, targetFile); } catch (IOException e) { e.printStackTrace(); } } } // refresh list view File dir = new File(targetDirPath); getFiles(dir.listFiles()); } }); ((MainAct) getActivity()).setOnBackPressedListener(new BaseBackPressedListener(MainAct.mAct)); return rootView; }
From source file:com.dm.material.dashboard.candybar.fragments.IconsSearchFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_icons_search, menu); MenuItem search = menu.findItem(R.id.menu_search); mSearchView = (SearchView) MenuItemCompat.getActionView(search); mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_SEARCH); mSearchView.setQueryHint(getActivity().getResources().getString(R.string.search_icon)); mSearchView.setMaxWidth(Integer.MAX_VALUE); MenuItemCompat.expandActionView(search); mSearchView.setIconifiedByDefault(false); mSearchView.clearFocus();/*from www .ja v a 2 s. c o m*/ int color = ColorHelper.getAttributeColor(getActivity(), R.attr.toolbar_icon); ViewHelper.changeSearchViewTextColor(mSearchView, color, ColorHelper.setColorAlpha(color, 0.6f)); View view = mSearchView.findViewById(android.support.v7.appcompat.R.id.search_plate); if (view != null) view.setBackgroundColor(Color.TRANSPARENT); ImageView closeIcon = (ImageView) mSearchView .findViewById(android.support.v7.appcompat.R.id.search_close_btn); if (closeIcon != null) closeIcon.setImageResource(R.drawable.ic_toolbar_close); ImageView searchIcon = (ImageView) mSearchView .findViewById(android.support.v7.appcompat.R.id.search_mag_icon); ViewHelper.removeSearchViewSearchIcon(searchIcon); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String string) { filterSearch(string); return true; } @Override public boolean onQueryTextSubmit(String string) { mSearchView.clearFocus(); return true; } }); }
From source file:com.google.reviewit.ReviewChangesFragment.java
private void addSeparator(ViewGroup viewGroup) { View separator = new View(getContext()); separator.setLayoutParams(matchAndFixedLayout(widgetUtil.dpToPx(1))); separator.setBackgroundColor(widgetUtil.color(R.color.separator)); viewGroup.addView(separator);/*from www .j a v a 2 s .co m*/ }
From source file:net.zionsoft.obadiah.ui.activities.SearchActivity.java
private void populateUi() { settings.refresh();//from w ww .ja va 2 s . c o m final View rootView = getWindow().getDecorView(); rootView.setKeepScreenOn(settings.keepScreenOn()); rootView.setBackgroundColor(settings.getBackgroundColor()); final String selected = getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE) .getString(Constants.PREF_KEY_LAST_READ_TRANSLATION, null); setTitle(selected); if (!selected.equals(nonConfigurationData.currentTranslation)) { nonConfigurationData.currentTranslation = selected; searchResultListAdapter.setVerses(null); } searchResultListAdapter.notifyDataSetChanged(); }
From source file:com.example.android.gft.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }// w ww. j ava 2 s.c om // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getMiwokTranslationId()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslationId()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
From source file:com.example.android.Spanish.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }/*from w ww . j a va 2s. c o m*/ // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getSpanishTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
From source file:com.example.android.tourguide.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }//from ww w .ja v a 2 s . com // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.tourguide_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getMiwokTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
From source file:com.example.shubh.miwok.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }/* w w w . ja v a2 s . c o m*/ // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getMiwokTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }