List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.abcvoipsip.ui.favorites.FavAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }//w w w .ja va2s . c o m if (type == ContactsWrapper.TYPE_GROUP) { showViewForHeader(view, true); TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); tv.setText(cv.getAsString(SipProfile.FIELD_DISPLAY_NAME)); icon.setImageResource(WizardUtils.getWizardIconRes(cv.getAsString(SipProfile.FIELD_WIZARD))); presSpinner.setProfileId(cv.getAsLong(BaseColumns._ID)); } else { showViewForHeader(view, false); ContactsWrapper.getInstance().bindContactView(view, context, cursor); } }
From source file:com.gammalabs.wifianalyzer.wifi.AccessPointsAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { WiFiDetail wiFiDetail = (WiFiDetail) getGroup(groupPosition); View view = accessPointDetail.makeView(convertView, parent, wiFiDetail, false); attachPopup(view, wiFiDetail);//from ww w.j a v a2 s .c o m ImageView groupIndicator = (ImageView) view.findViewById(R.id.groupIndicator); int childrenCount = getChildrenCount(groupPosition); if (childrenCount > 0) { groupIndicator.setVisibility(View.VISIBLE); groupIndicator.setImageResource( isExpanded ? R.drawable.ic_expand_less_black_24dp : R.drawable.ic_expand_more_black_24dp); groupIndicator.setColorFilter(ContextCompat.getColor(context, R.color.icons_color)); } else { groupIndicator.setVisibility(View.GONE); } return view; }
From source file:com.foxconn.lib.welcome.license.TestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.welcome_content, null); TextView welcome_content_subject_tv, welcome_content_subject_detail_tv; welcome_content_subject_tv = (TextView) layout.findViewById(R.id.welcome_content_subject_tv); welcome_content_subject_detail_tv = (TextView) layout.findViewById(R.id.welcome_content_subject_detail_tv); ImageView welcome_content_iconlay = (ImageView) layout.findViewById(R.id.welcome_content_iconlay) .findViewById(R.id.welcome_content_iconlay_iv); switch (content) { case 0:/*from w w w. j av a2 s . co m*/ layout.setBackgroundResource(R.drawable.qo_startup_screen1); welcome_content_iconlay.setImageResource(R.drawable.icon); break; case 1: layout.setBackgroundResource(R.drawable.qo_startup_screen2); welcome_content_subject_tv.setText(getString(R.string.emm_license_welcome_pager2_title)); welcome_content_subject_detail_tv.setText(getString(R.string.emm_license_welcome_pager2_content)); break; case 2: layout.setBackgroundResource(R.drawable.qo_startup_screen3); welcome_content_iconlay.setImageResource(R.drawable.icon); welcome_content_subject_tv.setText(getString(R.string.emm_license_welcome_pager3_title)); welcome_content_subject_detail_tv.setText(getString(R.string.emm_license_welcome_pager3_content)); break; default: break; } return layout; }
From source file:at.alladin.rmbt.android.views.ResultQoSDetailView.java
@SuppressWarnings("unchecked") @Override/*from ww w.java 2s .c om*/ public void taskEnded(JSONArray result) { System.out.println("ResultQoSDetail taskEnded"); this.testResult = result; if (resultFetchEndTaskListener != null) { resultFetchEndTaskListener.taskEnded(result); } ProgressBar resultProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar); TextView resultTextView = (TextView) view.findViewById(R.id.info_text); try { results = new QoSServerResultCollection(result); View successList = view.findViewById(R.id.qos_success_list); List<HashMap<String, String>> itemList = new ArrayList<HashMap<String, String>>(); int index = 0; for (QoSTestResultEnum type : QoSTestResultEnum.values()) { if (results.getQoSStatistics().getTestCounter(type) > 0) { HashMap<String, String> listItem = new HashMap<String, String>(); listItem.put("name", ConfigHelper.getCachedQoSNameByTestType(type, activity)); listItem.put("type_name", type.toString()); listItem.put("index", String.valueOf(index++)); itemList.add(listItem); } } ListAdapter valueList = new SimpleAdapter(activity, itemList, R.layout.qos_category_list_item, new String[] { "name" }, new int[] { R.id.name }); resultProgressBar.setVisibility(View.GONE); if (valueList.getCount() > 0) { //in case the view will change again: if (ListView.class.isAssignableFrom(successList.getClass())) { ((ListView) successList).setAdapter(valueList); ((ListView) successList).setOnItemClickListener(this); } else { ViewGroup vgList = (ViewGroup) successList; for (int i = 0; i < valueList.getCount(); i++) { View v = valueList.getView(i, null, null); QoSTestResultEnum key = QoSTestResultEnum .valueOf(((HashMap<String, String>) valueList.getItem(i)).get("type_name")); if (results.getQoSStatistics().getFailureCounter(key) > 0) { ImageView img = (ImageView) v.findViewById(R.id.status); img.setImageResource(R.drawable.traffic_lights_red); } TextView status = (TextView) v.findViewById(R.id.qos_type_status); status.setText((results.getQoSStatistics().getTestCounter(key) - results.getQoSStatistics().getFailedTestsCounter(key)) + "/" + results.getQoSStatistics().getTestCounter(key)); v.setOnClickListener(this); v.setTag(valueList.getItem(i)); vgList.addView(v); } } successList.invalidate(); resultTextView.setVisibility(View.GONE); successList.setVisibility(View.VISIBLE); } else { resultTextView.setText(R.string.result_qos_error_no_data_available); } } catch (Throwable t) { resultTextView.setText(R.string.result_qos_error_no_data_available); resultProgressBar.setVisibility(View.GONE); t.printStackTrace(); } }
From source file:br.com.projeto.icebeer.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_main, container, false); // evento botao3 Button botao = (Button) view.findViewById(R.id.bt3); botao.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { botaoSelecionado(BT3);/* w w w . j ava2 s . c o m*/ } }); // evento botao4 botao = (Button) view.findViewById(R.id.bt4); botao.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { botaoSelecionado(BT4); } }); // evento botao5 botao = (Button) view.findViewById(R.id.bt5); botao.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { botaoSelecionado(BT5); } }); ImageView imgLigar = (ImageView) view.findViewById(R.id.imgLigar); imgLigar.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { statusPower = !statusPower; ImageView _imgLigar = (ImageView) v.findViewById(R.id.imgLigar); if (statusPower) { _imgLigar.setImageResource(R.drawable.ic_ligado_150px); startTimer(); } else { _imgLigar.setImageResource(R.drawable.ic_desligado_150px); stoptimertask(); } } }); return view; }
From source file:com.example.android.saddacampus.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 w w. j a v a 2s .co 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; }
From source file:com.example.conallcurran.quick_click.English_Infants.java
private void zoomImageFromThumb(final View thumbView, int imageResId) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel();/* w w w . j a v a 2s .co m*/ } final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:de.aw.awlib.fragments.AWRemoteFileChooser.java
@Override public void onBindViewHolder(AWLibViewHolder holder, FTPFile file, int position) { TextView tv;/*from w ww . j ava 2s. co m*/ switch (holder.getItemViewType()) { case BACKTOPARENT: for (int resID : viewResIDs) { View view = holder.itemView.findViewById(resID); if (resID == R.id.folderImage) { ImageView img = (ImageView) view; img.setImageResource(R.drawable.ic_open_folder); } else if (resID == R.id.awlib_fileName) { tv = (TextView) view; if (mDirectoyList.size() == 0) { tv.setText("."); } else { tv.setText(file.getName()); } } else if (resID == R.id.awlib_fileData) { view.setVisibility(View.GONE); } } break; default: for (int resID : viewResIDs) { View view = holder.itemView.findViewById(resID); if (resID == R.id.folderImage) { ImageView img = (ImageView) view; if (file.isDirectory()) { img.setImageResource(R.drawable.ic_closed_folder); } else { img.setImageResource(R.drawable.ic_file_generic); } } else if (resID == R.id.awlib_fileName) { tv = (TextView) view; tv.setText(file.getName()); } else if (resID == R.id.awlib_fileData) { view.setVisibility(View.VISIBLE); tv = (TextView) view; tv.setText(Formatter.formatFileSize(getContext(), file.getSize())); } } } }
From source file:android.example.com.animationdemos.ZoomActivity.java
/** * "Zooms" in a thumbnail view by assigning the high resolution image to a hidden "zoomed-in" * image view and animating its bounds to fit the entire activity content area. More * specifically:/*w ww .j a v a2 s . c om*/ * <p/> * <ol> * <li>Assign the high-res image to the hidden "zoomed-in" (expanded) image view.</li> * <li>Calculate the starting and ending bounds for the expanded view.</li> * <li>Animate each of four positioning/sizing properties (X, Y, SCALE_X, SCALE_Y) * simultaneously, from the starting bounds to the ending bounds.</li> * <li>Zoom back out by running the reverse animation on click.</li> * </ol> * * @param thumbView The thumbnail view to zoom in. * @param imageResId The high-resolution version of the image represented by the thumbnail. */ private void zoomImageFromThumb(final View thumbView, int imageResId) { // If there's an animation in progress, cancel it immediately and proceed with this one. if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Load the high-resolution "zoomed-in" image. final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in image. This step // involves lots of math. Yay, math. final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, and the // final bounds are the global visible rectangle of the container view. Also // set the container view's offset as the origin for the bounds, since that's // the origin for the positioning animation properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); // Adjust the start bounds to be the same aspect ratio as the final bounds using the // "center crop" technique. This prevents undesirable stretching during the animation. // Also calculate the start scaling factor (the end scaling factor is always 1.0). float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { // Extend start bounds horizontally startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } // Hide the thumbnail and show the zoomed-in view. When the animation begins, // it will position the zoomed-in view in the place of the thumbnail. thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); // Set the pivot point for SCALE_X and SCALE_Y transformations to the top-left corner of // the zoomed-in view (the default is the center of the view). expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); // Construct and run the parallel animation of the four translation and scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; // Upon clicking the zoomed-in image, it should zoom back down to the original bounds // and show the thumbnail instead of the expanded image. final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:com.enadein.carlogbook.adapter.NotificationAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { int nameIdx = cursor.getColumnIndex(ProviderDescriptor.Notify.Cols.NAME); int trigerIdx = cursor.getColumnIndex(ProviderDescriptor.Notify.Cols.TRIGGER_VALUE); int typeIdx = cursor.getColumnIndex(ProviderDescriptor.Notify.Cols.TYPE); String name = cursor.getString(nameIdx); long trigerValue = cursor.getLong(trigerIdx); int type = cursor.getInt(typeIdx); ImageView imageView = (ImageView) view.findViewById(R.id.logo); TextView trigerView = (TextView) view.findViewById(R.id.value); TextView nameView = (TextView) view.findViewById(R.id.name); nameView.setText(name);/*ww w .j a v a 2 s . c om*/ if (type == ProviderDescriptor.Notify.Type.DATE) { imageView.setImageResource(R.drawable.date); trigerView.setText(CommonUtils.formatDate(new Date(trigerValue))); } else { imageView.setImageResource(R.drawable.odometer); trigerView.setText(String.valueOf(trigerValue)); } int pos = cursor.getPosition(); CommonUtils.runAnimation(mlastPos, pos, view, UnitFacade.animSize); mlastPos = pos; }