本文整理匯總了Java中android.widget.ImageView.setImageDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setImageDrawable方法的具體用法?Java ImageView.setImageDrawable怎麽用?Java ImageView.setImageDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setImageDrawable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playBy
import android.widget.ImageView; //導入方法依賴的package包/類
public void playBy(int startPosition, int nextPosition, PageSetEntity pageSetEntity) {
if (!checkPageSetEntity(pageSetEntity)) {
return;
}
updateIndicatorCount(pageSetEntity.getPageCount());
if (startPosition < 0 || nextPosition < 0 || nextPosition == startPosition) {
startPosition = nextPosition = 0;
}
if (startPosition < 0) {
startPosition = nextPosition = 0;
}
final ImageView imageViewStrat = mImageViews.get(startPosition);
final ImageView imageViewNext = mImageViews.get(nextPosition);
imageViewStrat.setImageDrawable(mDrawableNomal);
imageViewNext.setImageDrawable(mDrawableSelect);
}
示例2: setSuccessDrawable4Callback
import android.widget.ImageView; //導入方法依賴的package包/類
private void setSuccessDrawable4Callback(final Drawable drawable) {
final ImageView view = viewRef.get();
if (view != null) {
view.setScaleType(options.getImageScaleType());
if (drawable instanceof GifDrawable) {
if (view.getScaleType() == ImageView.ScaleType.CENTER) {
view.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (options.getAnimation() != null) {
ImageAnimationHelper.animationDisplay(view, drawable, options.getAnimation());
} else if (options.isFadeIn()) {
ImageAnimationHelper.fadeInDisplay(view, drawable);
} else {
view.setImageDrawable(drawable);
}
}
}
示例3: onFinishInflate
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onFinishInflate() {
super.onFinishInflate();
mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
mTimeLabel = (TextView) findViewById(R.id.time_label);
mDeviceLabel = (TextView) findViewById(R.id.device_label);
mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);
// Create drawable for expand/collapse arrow.
LevelListDrawable collapseIcon = new LevelListDrawable();
collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
TintedDrawable collapse =
TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
collapse.setTint(
ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
示例4: previewImages
import android.widget.ImageView; //導入方法依賴的package包/類
private void previewImages() {
mImagesLayout.setVisibility(mAttachedImages.isEmpty() ? View.GONE : View.VISIBLE);
for (ImageView imageView : mImageViews) {
imageView.setImageDrawable(null);
}
for (int i = 0; i < mAttachedImages.size(); ++i) {
Picasso.with(getActivity())
.load(mAttachedImages.get(i))
.into(mImageViews[i]);
final int finalI = i;
mImageViews[i].setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
mAttachedImages.remove(finalI);
previewImages();
return true;
}
});
}
}
示例5: setImageDrawable
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Called when the processing is complete and the final drawable should be
* set on the ImageView.
*
* @param imageView
* @param drawable
*/
private void setImageDrawable(ImageView imageView, Drawable drawable) {
if (mFadeInBitmap) {
// Transition drawable with a transparent drawable and the final drawable
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
new ColorDrawable(Color.TRANSPARENT),
drawable
});
// Set background to loading bitmap
imageView.setBackgroundDrawable(
new BitmapDrawable(mResources, mLoadingBitmap));
imageView.setImageDrawable(td);
td.startTransition(FADE_IN_TIME);
} else {
imageView.setImageDrawable(drawable);
}
}
示例6: setupViews
import android.widget.ImageView; //導入方法依賴的package包/類
private void setupViews() {
View view = LayoutInflater.from(getContext()).inflate(R.layout.view_medlinker_refresh_header, this);
loadingView = (ImageView) view.findViewById(R.id.iv_loadingview);
refreshState = (TextView) view.findViewById(R.id.tv_refresh_state);
int[] RES_IDS = new int[]{R.mipmap.loading_00000, R.mipmap.loading_00001, R.mipmap.loading_00002, R.mipmap.loading_00003, R.mipmap.loading_00004,
R.mipmap.loading_00005, R.mipmap.loading_00006, R.mipmap.loading_00007, R.mipmap.loading_00008, R.mipmap.loading_00009,
R.mipmap.loading_00010, R.mipmap.loading_00011, R.mipmap.loading_00012, R.mipmap.loading_00013, R.mipmap.loading_00014,
R.mipmap.loading_00015, R.mipmap.loading_00016, R.mipmap.loading_00017, R.mipmap.loading_00018, R.mipmap.loading_00019,
R.mipmap.loading_00020, R.mipmap.loading_00021, R.mipmap.loading_00022, R.mipmap.loading_00023, R.mipmap.loading_00024,
R.mipmap.loading_00025, R.mipmap.loading_00026, R.mipmap.loading_00027, R.mipmap.loading_00028, R.mipmap.loading_00029,
R.mipmap.loading_00030, R.mipmap.loading_00031, R.mipmap.loading_00032, R.mipmap.loading_00033, R.mipmap.loading_00034,
R.mipmap.loading_00035, R.mipmap.loading_00036, R.mipmap.loading_00037, R.mipmap.loading_00038, R.mipmap.loading_00039,
};
drawable = new FrameAnimDrawable(RES_IDS, getResources());
loadingView.setImageDrawable(drawable);
}
示例7: setRightBarButtonItemStateFromJS
import android.widget.ImageView; //導入方法依賴的package包/類
protected void setRightBarButtonItemStateFromJS(String data) {
// TODO Auto-generated method stub
int tag = 0;
boolean selectState = false;
try {
JSONObject jsonObject = new JSONObject(data);
tag = jsonObject.getInt("tag");
selectState = jsonObject.getBoolean("selectState");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] imageInfo = selectImageNames.get(tag);
ImageView rightButton = (ImageView) activity.findViewById(Integer.parseInt(imageInfo[2]));
String imageName = "";
if (selectState) {
imageName = imageInfo[1];
} else {
imageName = imageInfo[0];
}
int imageId = activity.getResources().getIdentifier(imageName, "drawable", activity.getPackageName());
if (imageId == 0) {
rightButton.setVisibility(View.GONE);
} else {
rightButton.setImageDrawable(activity.getResources().getDrawable(imageId));
rightButton.setVisibility(View.VISIBLE);
}
}
示例8: getView
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final Context context = parent.getContext();
if (convertView == null) {
final LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
}
final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
final View line2 = convertView.findViewById(R.id.line2);
final DocumentStack stack = getItem(position);
iconMime.setImageDrawable(stack.root.loadIcon(context));
final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());
final SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(stack.root.title);
for (int i = stack.size() - 2; i >= 0; i--) {
appendDrawable(builder, crumb);
builder.append(stack.get(i).displayName);
}
title.setText(builder);
title.setEllipsize(TruncateAt.MIDDLE);
if (line2 != null) line2.setVisibility(View.GONE);
return convertView;
}
示例9: SuggestionsViewHolder
import android.widget.ImageView; //導入方法依賴的package包/類
public SuggestionsViewHolder(View convertView) {
textView = (TextView) convertView.findViewById(R.id.suggestion_text);
if (suggestionIcon != null) {
imageView = (ImageView) convertView.findViewById(R.id.suggestion_icon);
imageView.setImageDrawable(suggestionIcon);
}
}
示例10: bindView
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void bindView(View convertView) {
final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon);
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
final TextView summary = (TextView) convertView.findViewById(android.R.id.summary);
final PackageManager pm = convertView.getContext().getPackageManager();
icon.setImageDrawable(info.loadIcon(pm));
title.setText(info.loadLabel(pm));
// TODO: match existing summary behavior from disambig dialog
summary.setVisibility(View.GONE);
}
示例11: loadThumbnail
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Load thumbnails for a directory list item.
* @param uri The URI for the file being represented.
* @param mimeType The mime type of the file being represented.
* @param docFlags Flags for the file being represented.
* @param iconThumb The itemview's thumbnail icon.
* @param iconMimeBackground
* @return
*/
public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon,
ImageView iconMime, ImageView iconThumb, View iconMimeBackground) {
boolean cacheHit = false;
final String docAuthority = uri.getAuthority();
String docId = DocumentsContract.getDocumentId(uri);
final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType);
final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled;
if (showThumbnail) {
final Bitmap cachedResult = mCache.get(uri);
if (cachedResult != null) {
iconThumb.setImageBitmap(cachedResult);
cacheHit = true;
iconMimeBackground.setVisibility(View.GONE);
} else {
iconThumb.setImageDrawable(null);
final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb,
iconMime, iconMimeBackground);
iconThumb.setTag(task);
ProviderExecutor.forAuthority(docAuthority).execute(task);
}
}
if (cacheHit) {
iconMime.setImageDrawable(null);
iconMime.setAlpha(0f);
iconThumb.setAlpha(1f);
} else {
// Add a mime icon if the thumbnail is being loaded in the background.
iconThumb.setImageDrawable(null);
iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon));
iconMime.setAlpha(1f);
iconThumb.setAlpha(0f);
}
}
示例12: animate
import android.widget.ImageView; //導入方法依賴的package包/類
public static void animate(final ImageView imageView, Drawable drawable1, Drawable drawable2) {
Drawable[] layers = new Drawable[2];
layers[0] = drawable1;
layers[1] = drawable2;
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
imageView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(5000);
}
示例13: newTopRightImageView
import android.widget.ImageView; //導入方法依賴的package包/類
/**新建右上方導航欄按鈕
* @param context
* @param drawable
* @return
*/
@SuppressLint({ "NewApi", "InflateParams" })
public ImageView newTopRightImageView(Context context, Drawable drawable) {
ImageView topRightButton = (ImageView) LayoutInflater.from(context).inflate(R.layout.top_right_iv, null);
topRightButton.setImageDrawable(drawable);
return topRightButton;
}
示例14: onCreate
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_keyframe_animation);
ImageView imageview = (ImageView) findViewById(R.id.imageview);
// Create the AnimationDrawable in which we will store all frames of the animation
final AnimationDrawable animationDrawable = new AnimationDrawable();
for (int i = 0; i < 10; ++i) {
animationDrawable.addFrame(getDrawableForFrameNumber(i), 300);
}
// Run until we say stop
animationDrawable.setOneShot(false);
imageview.setImageDrawable(animationDrawable);
// When the user clicks on the image, toggle the animation on/off
imageview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (animationDrawable.isRunning()) {
animationDrawable.stop();
} else {
animationDrawable.start();
}
}
});
}
示例15: onCreateDialog
import android.widget.ImageView; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.fragment_memo_dialog, null);
builder.setCancelable(false);
builder.setView(view);
((TextView)view.findViewById(R.id.txt_requester)).setText(getString(R.string.you_and) + sender + getString(R.string.scheduled_a_run_based_on));
TextView typeTxt = (TextView) view.findViewById(R.id.txt_challenge_type);
TextView dateDescriptionTxt = (TextView) view.findViewById(R.id.txt_date_description);
TextView dateTxt = (TextView) view.findViewById(R.id.txt_date);
TextView timeDescriptionTxt = (TextView) view.findViewById(R.id.txt_time_description);
TextView timeTxt = (TextView) view.findViewById(R.id.txt_time);
ImageView typeImg = (ImageView) view.findViewById(R.id.type_img);
if(type == Challenge.Type.TIME){
typeTxt.setText(R.string.Time);
typeImg.setImageDrawable(getResources().getDrawable(R.drawable.time_white));
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(scheduledDate);
dateDescriptionTxt.setText(getString(R.string.on_date));
dateTxt.setText(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)) + getString(R.string.dash) + String.valueOf(calendar.get(Calendar.MONTH)+1) + getString(R.string.dash) + String.valueOf(calendar.get(Calendar.YEAR)));
timeDescriptionTxt.setText(getString(R.string.at));
timeTxt.setText(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)) + getString((R.string.colon_with_space)) + String.valueOf(calendar.get(Calendar.MINUTE)));
dialog = builder.create();
view.findViewById(R.id.cancel_btn).setOnClickListener(this);
view.findViewById(R.id.decline_btn).setOnClickListener(this);
view.findViewById(R.id.accept_btn).setOnClickListener(this);
return dialog;
}