Java Code Examples for android.widget.ImageView#setImageResource()
The following examples show how to use
android.widget.ImageView#setImageResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageLoader.java From SaveVolley with Apache License 2.0 | 6 votes |
/** * The default implementation of ImageListener which handles basic functionality * of showing a default image until the network response is received, at which point * it will switch to either the actual image or the error image. * * @param view The imageView that the listener is associated with. * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist. * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist. */ public static ImageListener getImageListener(final ImageView view, final int defaultImageResId, final int errorImageResId) { return new ImageListener() { @Override public void onErrorResponse(VolleyError error) { if (errorImageResId != 0) { view.setImageResource(errorImageResId); } } @Override public void onResponse(ImageContainer response, boolean isImmediate) { if (response.getBitmap() != null) { view.setImageBitmap(response.getBitmap()); } else if (defaultImageResId != 0) { view.setImageResource(defaultImageResId); } } }; }
Example 2
Source File: BoxSearchView.java From box-android-browse-sdk with Apache License 2.0 | 6 votes |
@Override public boolean onQueryTextChange(String newText) { if (mOnBoxSearchListener != null) { mOnBoxSearchListener.onQueryTextChange(newText); } LinearLayout searchPlate = (LinearLayout)findViewById(R.id.search_plate); final ImageView searchCloseButton = (ImageView) searchPlate.findViewById(R.id.search_close_btn); if (searchCloseButton != null) { if (!newText.isEmpty()) { searchCloseButton.setImageResource(R.drawable.ic_searchclear); searchCloseButton.setClickable(true); } else { searchCloseButton.setImageResource(android.R.color.transparent); searchCloseButton.setClickable(false); } } // Don't perform default action, return true return true; }
Example 3
Source File: CallViewActivity.java From matrix-android-console with Apache License 2.0 | 6 votes |
/** * Insert the callView in the activity (above the other room member) * @param avatarUrl the other member avatar */ private void insertCallView(String avatarUrl) { ImageView avatarView = (ImageView)CallViewActivity.this.findViewById(R.id.call_other_member); avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light); if (!TextUtils.isEmpty(avatarUrl)) { int size = CallViewActivity.this.getResources().getDimensionPixelSize(R.dimen.member_list_avatar_size); mSession.getMediasCache().loadAvatarThumbnail(mSession.getHomeserverConfig(), avatarView, avatarUrl, size); } RelativeLayout layout = (RelativeLayout)CallViewActivity.this.findViewById(R.id.call_layout); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layout.addView(mCallView, 1, params); mCall.setVisibility(View.GONE); }
Example 4
Source File: EditPage.java From ShareSDKShareDifMsgDemo-Android with MIT License | 6 votes |
private ImageView getImagePin() { ivPin = new ImageView(getContext()); int resId = getBitmapRes(activity, "pin"); if (resId > 0) { ivPin.setImageResource(resId); } int dp_80 = dipToPx(getContext(), 80); int dp_36 = dipToPx(getContext(), 36); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(dp_80, dp_36); lp.topMargin = dipToPx(getContext(), 6); lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId()); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); ivPin.setLayoutParams(lp); ivPin.setVisibility(View.GONE); return ivPin; }
Example 5
Source File: DonateToMe.java From ADBToolKitsInstaller with GNU General Public License v3.0 | 5 votes |
private static void showSaveQRCodeDialog(Context context, int resId) { final ImageView imageView = new ImageView(context); imageView.setImageResource(resId); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); new AlertDialog.Builder(context).setView(imageView) .setNeutralButton(android.R.string.cancel, null) .setPositiveButton(R.string.title_donate_dialog_save_qr_code, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { saveImage(imageView); } }) .show(); }
Example 6
Source File: HomeSettingAdapter.java From Trivia-Knowledge with Apache License 2.0 | 5 votes |
@NonNull @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View view = inflater.inflate(R.layout.lv_homesetting_list_view, null, true); tv = (TextView) view.findViewById(R.id.tv11); Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/shablagooital.ttf"); tv.setTypeface(typeface); ImageView iv = (ImageView) view.findViewById(R.id.iv11); tv.setText(s[position]); tv.setTextSize(25); iv.setImageResource(img[position]); return view; }
Example 7
Source File: SimpleImageDialog.java From SimpleDialogFragments with Apache License 2.0 | 5 votes |
@Override protected View onCreateContentView(Bundle savedInstanceState) { View view; int scale = getArguments().getInt(SCALE_TYPE, Scale.FIT.nativeInt); if (scale == Scale.FIT.nativeInt){ view = inflate(R.layout.simpledialogfragment_image); } else if (scale == Scale.SCROLL_VERTICAL.nativeInt){ view = inflate(R.layout.simpledialogfragment_image_vert_scroll); } else if (scale == Scale.SCROLL_HORIZONTAL.nativeInt) { view = inflate(R.layout.simpledialogfragment_image_hor_scroll); } else { return null; } ImageView imageView = (ImageView) view.findViewById(R.id.image); ProgressBar loading = (ProgressBar) view.findViewById(R.id.progressBar); if (getArguments().containsKey(IMAGE_URI)) { imageView.setImageURI((Uri) getArguments().getParcelable(IMAGE_URI)); } else if (getArguments().containsKey(DRAWABLE_RESOURCE)) { imageView.setImageResource(getArguments().getInt(DRAWABLE_RESOURCE)); } else if (getArguments().containsKey(CREATOR_CLASS)) { Bundle args = getArguments(); args.putString(TAG, getTag()); new ImageCreator(imageView, loading).execute(args); } else if (getArguments().containsKey(BITMAP)) { imageView.setImageBitmap((Bitmap) getArguments().getParcelable(BITMAP)); } return view; }
Example 8
Source File: StarFollowAdapter.java From letv with Apache License 2.0 | 5 votes |
public View getView(int position, View convertView, ViewGroup viewGroup) { ViewHolder holder = ViewHolder.get(this.mContext, convertView, R.layout.item_star_follow); View follow_img = (ImageView) holder.getView(R.id.follow_img); ImageView follow_rank_icon = (ImageView) holder.getView(R.id.follow_rank_icon); TextView follow_name = (TextView) holder.getView(R.id.follow_name); TextView follow_vote_num = (TextView) holder.getView(R.id.follow_vote_num); StarFollowRankBean follow = (StarFollowRankBean) this.mData.get(position); if (follow == null) { return holder.getConvertView(); } ImageDownloader.getInstance().download(follow_img, follow.picture, 2130837905, new CustomConfig(BitmapStyle.ROUND, 0)); switch (position) { case 0: follow_rank_icon.setImageResource(2130838980); break; case 1: follow_rank_icon.setImageResource(2130838981); break; case 2: follow_rank_icon.setImageResource(2130838982); break; case 3: follow_rank_icon.setImageResource(2130838983); break; default: follow_rank_icon.setImageDrawable(null); break; } follow_name.setText(follow.nickname); if (TextUtils.isEmpty(follow.num)) { follow_vote_num.setVisibility(8); } else { follow_vote_num.setVisibility(0); String voteUnit = TipUtils.getTipMessage(DialogMsgConstantId.CONSTANT_700073, 2131100883); String fllow_num = getVoteCount(follow.num); follow_vote_num.setText(LetvTextUtils.changePartialTextAppearance(fllow_num + " " + voteUnit, 0, this.mContext.getResources().getDimensionPixelSize(2131165477), this.mContext.getResources().getColor(2131493346), 0, fllow_num.length())); } return holder.getConvertView(); }
Example 9
Source File: CameraActivity.java From Augendiagnose with GNU General Public License v2.0 | 5 votes |
/** * Set the thumb image from a file. * * @param file The file to be put in the thumb. * @param rightLeft The side of the eye */ private void setThumbImage(@Nullable final String file, final RightLeft rightLeft) { ImageView imageView = findViewById(rightLeft == RIGHT ? R.id.camera_thumb_image_right : R.id.camera_thumb_image_left); if (file != null) { Bitmap bitmap = ImageUtil.getImageBitmap(file, getResources().getDimensionPixelSize(R.dimen.camera_thumb_size)); imageView.setImageBitmap(bitmap); } else { imageView.setImageResource(rightLeft == RIGHT ? R.drawable.icon_eye_right : R.drawable.icon_eye_left); } }
Example 10
Source File: FuncView.java From pandora with Apache License 2.0 | 5 votes |
@SuppressLint("ClickableViewAccessibility") public FuncView(Context context) { super(context); setOrientation(HORIZONTAL); setBackgroundResource(R.drawable.pd_shadow_131124); ImageView moveView = new ImageView(context); RecyclerView recyclerView = new RecyclerView(context); ImageView closeView = new ImageView(context); moveView.setImageResource(R.drawable.pd_drag); moveView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); moveView.setOnTouchListener(touchListener); closeView.setImageResource(R.drawable.pd_close); closeView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); closeView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { close(); } }); recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); recyclerView.setAdapter(adapter = new UniversalAdapter()); addView(moveView, new LayoutParams( ViewKnife.dip2px(24), ViewGroup.LayoutParams.MATCH_PARENT )); addView(recyclerView, new LayoutParams( 0, ViewGroup.LayoutParams.MATCH_PARENT, 1 )); addView(closeView, new LayoutParams( ViewKnife.dip2px(40), ViewGroup.LayoutParams.MATCH_PARENT )); }
Example 11
Source File: TestFragmentActivity.java From AndroidPlugin with MIT License | 5 votes |
@Override public void onResume() { super.onResume(); mImageView = (ImageView) findViewById(R.id.imageView1); mImageView.setImageResource(R.drawable.ppmm); Log.d(TAG, "onResume"); }
Example 12
Source File: IntroActivity.java From WhatsAppStatusSaver with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intro); final SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); alreadyOpened = sharedPref.getBoolean("already-opened", false); if (!alreadyOpened) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("already-opened", true); editor.apply(); Handler handler = new Handler(); handler.postDelayed( new Runnable() { public void run() { startActivity(new Intent(IntroActivity.this, MainActivity.class)); finish(); } }, 21000L); } else { startActivity(new Intent(IntroActivity.this, MainActivity.class)); finish(); } mVisible = true; mControlsView = findViewById(R.id.fullscreen_content_controls); mContentView = findViewById(R.id.fullscreen_content); simpleViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); // get the reference of ViewFlipper // Set up the user interaction to manually show or hide the system UI. mContentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggle(); } }); for (int i = 0; i < images.length; i++) { // create the object of ImageView ImageView imageView = new ImageView(this); imageView.setImageResource(images[i]); // set image in ImageView simpleViewFlipper.addView(imageView); // add the created ImageView in ViewFlipper } // Declare in and out animations and load them using AnimationUtils class Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); // set the animation type's to ViewFlipper simpleViewFlipper.setInAnimation(in); simpleViewFlipper.setOutAnimation(out); // set interval time for flipping between views simpleViewFlipper.setFlipInterval(3000); // set auto start for flipping between views simpleViewFlipper.setAutoStart(true); }
Example 13
Source File: MainActivity.java From astrobee_android with Apache License 2.0 | 4 votes |
/** * Alternative method for displayBatteryLevelSimple. * * @param battery Battery object. * @param display Java ImageView object. * @param textPercentage Java TextView object. */ protected void displayBatteryLevel(Battery battery, ImageView display, TextView textPercentage) { String batteryLevelAprox = battery.getBatteryLevelAprox(); String percentage = (int) battery.getPercentage() + "%"; switch (batteryLevelAprox) { case Battery.BATTERY_EMPTY: display.setImageResource(R.drawable.battery_empty); break; case Battery.BATTERY_5: display.setImageResource(R.drawable.battery_5); break; case Battery.BATTERY_10: display.setImageResource(R.drawable.battery_10); break; case Battery.BATTERY_20: display.setImageResource(R.drawable.battery_20); break; case Battery.BATTERY_30: display.setImageResource(R.drawable.battery_30); break; case Battery.BATTERY_40: display.setImageResource(R.drawable.battery_40); break; case Battery.BATTERY_50: display.setImageResource(R.drawable.battery_50); break; case Battery.BATTERY_60: display.setImageResource(R.drawable.battery_60); break; case Battery.BATTERY_70: display.setImageResource(R.drawable.battery_70); break; case Battery.BATTERY_80: display.setImageResource(R.drawable.battery_80); break; case Battery.BATTERY_90: display.setImageResource(R.drawable.battery_90); break; case Battery.BATTERY_95: display.setImageResource(R.drawable.battery_95); break; case Battery.BATTERY_100: display.setImageResource(R.drawable.battery_100); break; case Battery.NO_BATTERY: display.setImageResource(R.drawable.no_battery); break; case Battery.BATTERY_ERROR: display.setImageResource(R.drawable.no_battery); break; default: break; } textPercentage.setText(percentage); }
Example 14
Source File: ViewHolder.java From SmartChart with Apache License 2.0 | 4 votes |
public ViewHolder setImageResource(int viewId, int resId) { ImageView view = getView(viewId); view.setImageResource(resId); return this; }
Example 15
Source File: BannerActivity.java From YViewPagerDemo with Apache License 2.0 | 4 votes |
private void initImgs() { mImageViews = new ArrayList<>(); mStringList=new ArrayList<>(); ViewPager.LayoutParams lp = new ViewPager.LayoutParams(); lp.gravity = Gravity.LEFT; ImageView imageView1 = new ImageView(this); imageView1.setImageResource(R.drawable.jay_fantexi); imageView1.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView2 = new ImageView(this); imageView2.setImageResource(R.drawable.jay_jay); imageView2.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView3 = new ImageView(this); imageView3.setImageResource(R.drawable.logo); imageView3.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView4 = new ImageView(this); imageView4.setImageResource(R.drawable.image2); imageView4.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView5 = new ImageView(this); imageView5.setImageResource(R.drawable.jay_jay); imageView5.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView6 = new ImageView(this); imageView6.setImageResource(R.drawable.logo); imageView6.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView1.setLayoutParams(lp); imageView2.setLayoutParams(lp); imageView3.setLayoutParams(lp); imageView4.setLayoutParams(lp); imageView5.setLayoutParams(lp); imageView6.setLayoutParams(lp); mImageViews.add(imageView1); mImageViews.add(imageView2); mImageViews.add(imageView3); mImageViews.add(imageView4); mImageViews.add(imageView5); mImageViews.add(imageView6); mStringList.add("youngkaaa test 1"); mStringList.add("hahahahha"); mStringList.add("yyyyyyyyyyyyyyy"); mStringList.add("aaaaaaaaaaaaaa"); mStringList.add("pipipipipipipipipi"); mStringList.add("kkkkkkkkkkkkkkkkk"); }
Example 16
Source File: AttachPopupWindow.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void initView(final Context context) { ImageView close = (ImageView) mConvertView.findViewById(R.id.image_pop_bbs_subject_attach_list_close); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); recyclerView = (RecyclerView) mConvertView.findViewById(R.id.recycler_pop_bbs_subject_attach_list); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); recyclerView.setLayoutManager(linearLayoutManager); if (itemDecoration==null) { itemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST); }else { recyclerView.removeItemDecoration(itemDecoration); } recyclerView.addItemDecoration(itemDecoration); adapter = new CommonRecycleViewAdapter<AttachmentItemVO>(context, attachList, R.layout.item_bbs_subject_attach_list) { @Override public void convert(CommonRecyclerViewHolder holder, AttachmentItemVO bbsSubjectAttachmentData) { int res = FileExtensionHelper.getImageResourceByFileExtension(bbsSubjectAttachmentData.getExtension()); holder.setText(R.id.tv_item_bbs_subject_attach_title, bbsSubjectAttachmentData.getName()) .setImageViewResource(R.id.image_item_bbs_subject_attach_icon, res); if (listener!=null) { AttachStatus status = listener.getAttachStatus(bbsSubjectAttachmentData.getId()); ImageView statusImage = holder.getView(R.id.image_item_bbs_subject_attach_status); CircleProgressBar circle = holder.getView(R.id.image_item_bbs_subject_attach_downloading); if (AttachStatus.ONCLOUD.equals(status)) { statusImage.setImageResource(R.mipmap.icon_bbs_attach_download); statusImage.setVisibility(View.VISIBLE); circle.setVisibility(View.GONE); }else if (AttachStatus.DOWNLOADCOMPLETED.equals(status)) { statusImage.setImageResource(R.mipmap.icon_bbs_attach_open); statusImage.setVisibility(View.VISIBLE); circle.setVisibility(View.GONE); }else if (AttachStatus.DOWNLOADING.equals(status)) { statusImage.setVisibility(View.GONE); circle.setVisibility(View.VISIBLE); } } } }; recyclerView.setAdapter(adapter); adapter.setOnItemClickListener(new CommonRecycleViewAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { AttachmentItemVO data = attachList.get(position); if (listener!=null) { AttachStatus status = listener.getAttachStatus(data.getId()); if (AttachStatus.ONCLOUD.equals(status)) { ImageView statusImage = (ImageView) view.findViewById(R.id.image_item_bbs_subject_attach_status); CircleProgressBar circle = (CircleProgressBar) view.findViewById(R.id.image_item_bbs_subject_attach_downloading); statusImage.setVisibility(View.GONE); circle.setVisibility(View.VISIBLE); listener.startDownLoadFile(data.getId()); }else if (AttachStatus.DOWNLOADCOMPLETED.equals(status)) { listener.openCompletedFile(data.getId()); }else if (AttachStatus.DOWNLOADING.equals(status)) { XToast.INSTANCE.toastShort(context, "附件下载中,请稍后再试!"); } } } }); }
Example 17
Source File: PbChatActivity.java From imsdk-android with MIT License | 4 votes |
/** * at消息提示 */ @SuppressLint("ObjectAnimatorBinding") public void showAtmsgView() { if (isFinishing()) { return; } ImageView tipImage = new ImageView(PbChatActivity.this); tipImage.setImageResource(R.drawable.atom_ui_chat_unread_tip); final TextView textView = new TextView(PbChatActivity.this); int padding = Utils.dipToPixels(PbChatActivity.this, 4); int size = Utils.dipToPixels(PbChatActivity.this, 30); int topMargin = Utils.dipToPixels(PbChatActivity.this, 70); final LinearLayout linearLayout = new LinearLayout(PbChatActivity.this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); linearLayout.setBackgroundResource(R.drawable.atom_ui_float_tab); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, size); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.setMargins(0, topMargin, 0, 0); linearLayout.setPadding(padding * 2, padding, padding * 2, padding); linearLayout.setLayoutParams(layoutParams); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); String msg = MessageFormat.format(getString(R.string.atom_ui_tip_somebody_at_you), atMsgIndexs.size()); textView.setText(msg); textView.setTextColor(Color.parseColor("#EB524A")); textView.setPadding(padding * 2, 0, 0, 0); textView.setOnClickListener(v -> { chat_region.getRefreshableView().smoothScrollToPosition(atMsgIndex); clearAtmsgTip(); }); linearLayout.addView(tipImage); linearLayout.addView(textView); linearLayout.setTag(TAG_ATMSG_VIEW); final LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1)); getHandler().postDelayed(() -> { if (!isFinishing()) { chating_view.setLayoutTransition(layoutTransition); chating_view.addView(linearLayout); } }, 500); }
Example 18
Source File: PinyinAdapter.java From weixin with Apache License 2.0 | 4 votes |
@Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.cgt_layout_addressbook_item, null); } TextView mTv_userName = (TextView) convertView.findViewById(R.id.cgt_tv_userName); ImageView mIv_userPhoto = (ImageView) convertView.findViewById(R.id.cgt_iv_userPhoto); View mV_line = convertView.findViewById(R.id.cgt_v_line); if (groupPosition == 0) { switch (childPosition) { case 0: mTv_userName.setText(context.getResources().getString(R.string.text_addressbook_newFriend)); mIv_userPhoto.setImageResource(R.drawable.cgt_addressbook_newfriend); break; case 1: mTv_userName.setText(context.getResources().getString(R.string.text_addressbook_groupChat)); mIv_userPhoto.setImageResource(R.drawable.cgt_addressbook_groupchat); break; case 2: mTv_userName.setText(context.getResources().getString(R.string.text_addressbook_mark)); mIv_userPhoto.setImageResource(R.drawable.cgt_addressbook_mark); break; case 3: mTv_userName.setText(context.getResources().getString(R.string.text_addressbook_publicNumber)); mIv_userPhoto.setImageResource(R.drawable.cgt_addressbook_publicnumber); break; default: break; } } else { mTv_userName.setText(mAssortPinyinList.getHashList().getValueThroughIndexAndKey(groupPosition, childPosition).getUserAccount()); String userPhote = mAssortPinyinList.getHashList().getValueThroughIndexAndKey(groupPosition, childPosition).getUserPhote(); if (userPhote == null) { mIv_userPhoto.setImageResource(R.drawable.user_picture); } else { mIv_userPhoto.setImageResource(Integer.parseInt(mAssortPinyinList.getHashList().getValueThroughIndexAndKey(groupPosition, childPosition).getUserPhote())); } } if (isLastChild) { mV_line.setVisibility(View.GONE); } else { mV_line.setVisibility(View.VISIBLE); } convertView.setTag(R.id.cgt_tv_addressbook_content, groupPosition); convertView.setTag(R.id.cgt_tv_addressbook_group_item, childPosition); return convertView; }
Example 19
Source File: RobotInfoAdapter.java From RobotCA with GNU General Public License v3.0 | 4 votes |
/** * Creates a ViewHolder for the specified View. * @param v The View */ public ViewHolder(View v) { super(v); v.setClickable(true); v.setOnClickListener(this); mRobotNameTextView = (TextView) v.findViewById(R.id.robot_name_text_view); mMasterUriTextView = (TextView) v.findViewById(R.id.master_uri_text_view); mEditButton = (ImageButton) v.findViewById(R.id.robot_edit_button); mEditButton.setOnClickListener(this); mDeleteButton = (ImageButton) v.findViewById(R.id.robot_delete_button); mDeleteButton.setOnClickListener(this); mImageView = (ImageView) v.findViewById(R.id.robot_wifi_image); mImageView.setImageResource(R.drawable.wifi_0); Timer t = new Timer(); t.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { int position = getAdapterPosition(); final RobotInfo info = mDataset.get(position); //mImageView.setLayoutParams(new ActionBar.LayoutParams(mEditButton.getHeight(), mEditButton.getHeight())); if (isPortOpen(info.getUri().getHost(), info.getUri().getPort(), 10000)) { activity.runOnUiThread(new Runnable() { @Override public void run() { mImageView.setImageResource(R.drawable.wifi_4); } }); } else { activity.runOnUiThread(new Runnable() { @Override public void run() { mImageView.setImageResource(R.drawable.wifi_0); } }); } Thread.sleep(10000); } catch (Exception ignore) { } } }, 1000, 15000); }
Example 20
Source File: ViewHolder.java From base-imageloader with Apache License 2.0 | 3 votes |
/** * 为ImageView设置图片 * * @param viewId * @param drawableId * @return */ public ViewHolder setImageResource(int viewId, int drawableId) { ImageView view = getView(viewId); view.setImageResource(drawableId); return this; }