List of usage examples for android.view View setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:com.shinymayhem.radiopresets.FragmentStations.java
@SuppressWarnings("deprecation") /*public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {/*from w w w.j ava 2 s . c om*/ String str= "list item longclicked"; if (LOCAL_LOGV) log(str, "v"); boolean checked = true; ListView listView = (ListView) adapterView; listView.setItemChecked(position, checked); //view.setBackgroundColor(getResources().getColor(R.color.blue)); //SparseBooleanArray checkedPositions = listView.getCheckedItemPositions(); //int checkedCount = listView.getCheckedItemCount(); //long[] var = listView.getCheckedItemIds(); //view.setSelected(true); //listView.startActionMode(this); mActionMode = this.getSherlockActivity().startActionMode(this); mActionMode.setTitle(this.getCheckedItemCount() + " " + getResources().getString(R.string.selected)); return true; } */ /* @Override public void onItemClick(AdapterView<?> adapterView, View item, int position, long id) { if (LOCAL_LOGV) log("onItemClick()", "v"); if (mActionMode != null) //in multi-select mode. click = check { //boolean checked = item.isSelected().isActivated(); SparseBooleanArray checkedArray = ((ListView) adapterView).getCheckedItemPositions(); boolean checked = checkedArray.get(position); int count = this.getCheckedItemCount(); mActionMode.setTitle(String.valueOf(count) + " " + getResources().getString(R.string.selected)); //mode.setSubtitle("Subtitle"); String str = "Position " + String.valueOf(position) + " "; //RelativeLayout item = (RelativeLayout) mListView.getChildAt(position); //item.setActivated(checked); if (checked) { //Object item = mListView.getItemAtPosition(position); //item.setBackgroundColor("android:attr/activatedBackgroundColor"); str += "checked"; item.setBackgroundColor(getResources().getColor(R.color.blue)); } else { str += "unchecked"; //item.setBackgroundColor(getResources().getColor(android.R.color.transparent)); item.setBackgroundColor(getResources().getColor(R.color.white)); } if (LOCAL_LOGV) log(str, "v"); if (count < 1) { mActionMode.finish(); } else { mActionMode.invalidate(); } } else //not in selection mode, play clicked item { Cursor cursor = (Cursor)adapterView.getItemAtPosition(position); //final String url = cursor.getString(cursor.getColumnIndexOrThrow(DbContractRadio.EntryStation.COLUMN_NAME_URL)); final int preset = Integer.valueOf(cursor.getString(cursor.getColumnIndexOrThrow(DbContractRadio.EntryStation.COLUMN_NAME_PRESET_NUMBER))); String str= "list item clicked, play preset " + preset + ". view position:"; str += Integer.toString(position); str += ", row id:"; str += Long.toString(id); if (LOCAL_LOGV) log(str, "v"); mListener.play(preset); } }*/ @SuppressLint("NewApi") public void highlightPosition(int position) { View view = (View) mListView.getChildAt(position); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(getResources().getDrawable(R.drawable.list_item_background_playing)); } else { view.setBackgroundDrawable(getResources().getDrawable(R.drawable.list_item_background_playing)); } }
From source file:com.shopify.buy.ui.ProductDetailsFragmentView.java
private void initializeImageOverlay() { View imageOverlay = findViewById(R.id.image_overlay); imageOverlayBackgroundDrawable = new ColorDrawable(theme.getAppBarBackgroundColor(getResources())); imageOverlayBackgroundDrawable.setAlpha(0); imageOverlay.setBackgroundDrawable(imageOverlayBackgroundDrawable); }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private Bitmap setScaledImage(final Drawable bgImage, View view, Bitmap prevScaled) { if (bgImage != null) { if (prevScaled != null) prevScaled.recycle();/* w w w . j av a 2s.c o m*/ int screenWidthPx = Resources.getSystem().getDisplayMetrics().widthPixels; int viewHeightPx = view.getMeasuredHeight(); // view.setBackgroundResource(bgImage); if (bgImage instanceof BitmapDrawable) { BitmapDrawable bmDrawable = (BitmapDrawable) bgImage; Bitmap bmImage = bmDrawable.getBitmap(); prevScaled = scaleCenterCrop(bmImage, screenWidthPx, viewHeightPx); view.setBackgroundDrawable(new BitmapDrawable(prevScaled)); } else { // TODO - compute scale factor from screenWidthPx and viewHeightx Drawable scaleDrawable = new ScaleDrawable(bgImage, Gravity.NO_GRAVITY, 1.0f, 0.1f); view.setBackgroundDrawable(scaleDrawable); } } return prevScaled; }
From source file:com.shinymayhem.radiopresets.CursorAdapterStations.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override/*from w ww . j av a 2 s.c o m*/ public void bindView(View view, Context context, Cursor cursor) { TextView titleView = (TextView) view.findViewById(R.id.station_title); int preset = (int) cursor .getLong(cursor.getColumnIndexOrThrow(DbContractRadio.EntryStation.COLUMN_NAME_PRESET_NUMBER)); String station = cursor .getString(cursor.getColumnIndexOrThrow(DbContractRadio.EntryStation.COLUMN_NAME_TITLE)); String text = String.valueOf(preset) + ". " + station; titleView.setText(text); int drawable; if (((ActivityMain) mContext).getPlayingPreset() == preset) { drawable = R.drawable.list_item_background_playing; } else { drawable = R.drawable.list_item_background; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(mContext.getResources().getDrawable(drawable)); } else { view.setBackgroundDrawable(mContext.getResources().getDrawable(drawable)); } }
From source file:com.gh4a.BaseActivity.java
@SuppressWarnings("deprecation") private void assignBackground(View view, int color) { if (view == null) { return;// w w w .j a v a 2 s . c o m } ColorDrawable background = ColorDrawable.create(color); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } else { view.setBackgroundDrawable(background); } mHeaderDrawables.add(background); }
From source file:de.escoand.readdaily.PlayerDialogFragment.java
@Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { final View root = inflater.inflate(R.layout.fragment_player, null); final TextView playerTitle = (TextView) root.findViewById(R.id.player_title); final ImageView playerImage = (ImageView) root.findViewById(R.id.player_image); progressBar = (ProgressBar) root.findViewById(R.id.player_progress); progressText = (TextView) root.findViewById(R.id.player_text); if (savedInstanceState != null) { setDate(getContext(), Database.getDateFromInt(savedInstanceState.getInt(STATE_DATE))); player.seekTo(savedInstanceState.getInt(STATE_POSITION)); }/* w ww .ja v a 2 s .c o m*/ if (image > 0) { final Bitmap tmp = BitmapFactory.decodeResource(getResources(), image); final int width = Math.round(tmp.getWidth() / 100); final int height = Math.round(tmp.getHeight() / 100); root.setBackgroundDrawable(new BitmapDrawable(Bitmap.createScaledBitmap(tmp, width, height, false))); playerImage.setImageResource(image); } playerTitle.setText(title); return root; }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private View generateRevealCircle() { int diameter = mFAB.getType() == FloatingActionButton.TYPE_NORMAL ? Utils.getDimension(mContext, R.dimen.fab_size_normal) : Utils.getDimension(mContext, R.dimen.fab_size_mini); View view = new View(mContext); OvalShape ovalShape = new OvalShape(); ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape); shapeDrawable.getPaint().setColor(ContextCompat.getColor(mContext, mRevealColor)); view.setBackgroundDrawable(shapeDrawable); LayoutParams lp = new LayoutParams(diameter, diameter); view.setLayoutParams(lp);/* w ww. ja v a 2 s . c o m*/ // Make view clickable to avoid clicks on any view located behind the menu view.setClickable(true); // note it is invisible, but will be visible while animating view.setVisibility(View.GONE); return view; }
From source file:com.facebook.litho.MountState.java
@SuppressWarnings("deprecation") private static void setBackgroundCompat(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(drawable); } else {/* ww w.j a v a 2s . c om*/ view.setBackground(drawable); } }
From source file:org.mythdroid.remote.TVRemote.java
private void setBackground(final int id, final Program prog, final View v) { final Drawable metal = getResources().getDrawable(R.drawable.metal); if (!Globals.haveServices()) { v.setBackgroundDrawable(metal); return;/*from w w w. j av a 2s . co m*/ } final DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); final int height = (int) (dm.heightPixels / 1.5); final int width = (int) (dm.widthPixels / 1.5); final ArtworkType type = (width > height) ? ArtworkType.fanart : ArtworkType.coverart; Globals.runOnThreadPool(new Runnable() { @Override public void run() { Bitmap bm = null; if (videoId != -1) bm = Video.getArtwork(id, type, width, 0, null); else if (prog != null) bm = prog.getArtwork(type, width, 0); final Drawable d = (bm == null) ? metal : new BitmapDrawable(getResources(), bm); if (bm != null) d.setAlpha(65); handler.post(new Runnable() { @Override public void run() { if (v == null) return; v.setBackgroundDrawable(d); } }); } }); }
From source file:org.videolan.vlc.util.HttpImageLoader.java
@Override public void updateImage(final Bitmap bitmap, final View target) { if (bitmap == null || bitmap.getWidth() == 1 || bitmap.getHeight() == 1) return;//from w ww. j av a 2 s.c o m if (mBinding != null) { mBinding.removeOnRebindCallback(rebindCallbacks); if (bindChanged) return; mBinding.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER); mBinding.setVariable(BR.image, new BitmapDrawable(VLCApplication.getAppResources(), bitmap)); mBinding.setVariable(BR.protocol, null); } else { sHandler.post(new Runnable() { @Override public void run() { if (target instanceof ImageCardView) ((ImageCardView) target).setMainImage(new BitmapDrawable(target.getResources(), bitmap)); else if (target instanceof ImageView) ((ImageView) target).setImageBitmap(bitmap); else if (target instanceof TextView) target.setBackgroundDrawable(new BitmapDrawable(target.getResources(), bitmap)); } }); } }