List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.bilibili.socialize.share.utils.selector.BaseSharePlatformSelector.java
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) { GridView grid = new GridView(context); ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) { // no need scroll @Override/*from w w w . j av a2 s .c o m*/ public View getView(int position, View convertView, ViewGroup parent) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.bili_socialize_shareboard_item, parent, false); view.setBackgroundDrawable(null); ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image); TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name); ShareTarget target = getItem(position); image.setImageResource(target.iconId); platform.setText(target.titleId); return view; } }; grid.setNumColumns(-1); grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size)); grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2)); grid.setSelector(R.drawable.bili_socialize_selector_item_background); grid.setAdapter(adapter); grid.setOnItemClickListener(onItemClickListener); return grid; }
From source file:com.eyekabob.util.EyekabobHelper.java
public static Dialog createAboutDialog(Context context) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dialog); dialog.setTitle(R.string.about_eyekabob_caps); ImageView imageView = (ImageView) dialog.findViewById(R.id.aboutDialogImage); imageView.setImageResource(R.drawable.ic_launcher); String message = context.getResources().getString(R.string.eyekabob_version); String versionName = ""; try {/* w w w. ja va 2 s . c o m*/ versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.e(context.getClass().getSimpleName(), e.getMessage()); } message += versionName; message += "\n\n" + context.getResources().getString(R.string.about_eyekabob_app); message += "\n\n" + context.getResources().getString(R.string.about_last_fm); TextView textView = (TextView) dialog.findViewById(R.id.aboutDialogText); textView.setText(message); dialog.findViewById(R.id.aboutDialogButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); return dialog; }
From source file:com.evvsoft.treeview.SimpleJsonTreeViewAdapter.java
/** * Called by bindView() to set the image for an ImageView but only if * there is no existing ViewBinder or if the existing ViewBinder cannot * handle binding to an ImageView./*from www .ja v a 2 s .c om*/ * * This method is called instead of {@link #setViewImage(ImageView, String)} * if the supplied data is an int or Integer. * * @param v ImageView to receive an image * @param value the value retrieved from the data set * * @see #setViewImage(ImageView, String) */ public static void setViewImage(ImageView v, int value) { v.setImageResource(value); }
From source file:com.evvsoft.treeview.SimpleJsonTreeViewAdapter.java
/** * Called by bindView() to set the image for an ImageView but only if * there is no existing ViewBinder or if the existing ViewBinder cannot * handle binding to an ImageView.//from w ww . j a v a 2 s . c o m * * By default, the value will be treated as an image resource. If the * value cannot be used as an image resource, the value is used as an * image Uri. * * This method is called instead of {@link #setViewImage(ImageView, int)} * if the supplied data is not an int or Integer. * * @param v ImageView to receive an image * @param value the value retrieved from the data set * * @see #setViewImage(ImageView, int) */ public static void setViewImage(ImageView v, String value) { try { v.setImageResource(Integer.parseInt(value)); } catch (NumberFormatException nfe) { v.setImageURI(Uri.parse(value)); } }
From source file:Main.java
/** * Creates an animation that rotates an {@link ImageView} * around the Y axis by 180 degrees and changes the image * resource shown when the view is rotated 90 degrees to the user. * * @param imageView the view to rotate. * @param drawableRes the drawable to set when the view * is rotated by 90 degrees. * @return an animation that will change the image shown by the view. *///from w w w .j a v a 2s . com @NonNull public static Animation createRotationTransitionAnimation(@NonNull final ImageView imageView, @DrawableRes final int drawableRes) { Animation animation = new Animation() { private boolean mSetFinalDrawable; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (interpolatedTime < 0.5f) { imageView.setRotationY(90 * interpolatedTime * 2f); } else { if (!mSetFinalDrawable) { mSetFinalDrawable = true; imageView.setImageResource(drawableRes); } imageView.setRotationY((-90) + (90 * (interpolatedTime - 0.5f) * 2f)); } } }; animation.setDuration(300); animation.setInterpolator(new AccelerateDecelerateInterpolator()); return animation; }
From source file:com.cloverstudio.spika.utils.Utils.java
public static void displayImage(String fileId, ImageView imageView, String size, int stubId, boolean downloadFromUrl) { if (fileId != null && !fileId.equals("null") && !fileId.equals("")) { ImageLoader.getImageLoader().DisplayImage(fileId, imageView, size, downloadFromUrl); } else {//from w w w . ja va2 s. c om ImageLoader.getImageLoader().cancelDisplayTaskFor(imageView); imageView.setImageResource(stubId); } }
From source file:ca.psiphon.ploggy.Robohash.java
public static void setRobohashImage(Context context, ImageView imageView, boolean cacheCandidate, Identity.PublicIdentity publicIdentity) { if (publicIdentity != null) { try {/*from w ww . j a v a 2 s . co m*/ imageView.setImageBitmap( Robohash.getRobohash(context, cacheCandidate, publicIdentity.getFingerprint())); return; } catch (Utils.ApplicationError e) { Log.addEntry(LOG_TAG, "failed to create image"); } } imageView.setImageResource(R.drawable.ic_unknown_avatar); }
From source file:com.crossconnect.activity.MainActivity.java
private static View createTabView(final Context context, final String text, int iconDrawable) { View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null); TextView tv = (TextView) view.findViewById(R.id.tabsText); ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon); iv.setImageResource(iconDrawable); tv.setText(text);/* w w w . j a v a 2s . co m*/ return view; }
From source file:com.csipsimple.utils.ContactsAsyncHelper.java
private static void defaultImage(ImageView imageView, int placeholderImageResource) { Log.v(THIS_FILE, "No uri, just display placeholder."); PhotoViewTag photoTag = new PhotoViewTag(); photoTag.uri = null;//from w w w . j a v a2s. com imageView.setTag(TAG_PHOTO_INFOS, photoTag); imageView.setVisibility(View.VISIBLE); imageView.setImageResource(placeholderImageResource); }
From source file:com.cloverstudio.spika.utils.Utils.java
/** * /*from w ww. j av a 2s .c o m*/ * @param fileId * @param imageView * @param progressBar * @param size * @param stubId */ public static void displayImage(String fileId, ImageView imageView, ProgressBar progressBar, String size, int stubId, boolean downloadFromUrl) { if (fileId != null && !fileId.equals("null") && !fileId.equals("")) { ImageLoader.getImageLoader().DisplayImage(fileId, imageView, progressBar, size, downloadFromUrl); } else { ImageLoader.getImageLoader().cancelDisplayTaskFor(imageView); imageView.setImageResource(stubId); progressBar.setVisibility(View.GONE); } }