List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.collabora.xwperf.notxw_contacts.fragments.DetailsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.details_menu, menu); if (contactModel == null) return;//from ww w. j ava 2 s . c om View saveView = menu.findItem(R.id.action_favorites).getActionView(); final ImageView favImage = (ImageView) saveView.findViewById(R.id.action_fav_image); saveView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { contactModel.setFavorite(!contactModel.isFavorite()); favImage.setImageResource(contactModel.isFavorite() ? R.drawable.btn_rating_star_on_mtrl_alpha : R.drawable.btn_rating_star_off_mtrl_alpha); } }); favImage.setImageResource(contactModel.isFavorite() ? R.drawable.btn_rating_star_on_mtrl_alpha : R.drawable.btn_rating_star_off_mtrl_alpha); showItem(contactModel); setTitle(contactModel.getName()); }
From source file:com.foodie.app.Activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.home_actions, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchMenuItem = menu.findItem(R.id.id_action_search); SearchView searchView = null;//from w w w . ja va2s . c o m if (searchMenuItem != null) { searchView = (SearchView) searchMenuItem.getActionView(); } if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName())); } SearchView.SearchAutoComplete searchAutoComplete = (SearchView.SearchAutoComplete) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchAutoComplete.setHintTextColor(Color.WHITE); searchAutoComplete.setTextColor(Color.WHITE); searchAutoComplete.setHint("?,,"); //? searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { //Toast.makeText(MainActivity.this,""+query,Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, SearchResultsActivity.class); intent.putExtra("query", query); startActivity(intent); return true; } @Override public boolean onQueryTextChange(String newText) { //Toast.makeText(MainActivity.this,""+newText,Toast.LENGTH_SHORT).show(); return false; } }); //?? View searchplate = (View) searchView.findViewById(android.support.v7.appcompat.R.id.search_plate); //searchplate.setBackgroundResource(R.drawable.ic_search_white_24dp); ImageView searchCloseIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_close_btn); searchCloseIcon.setImageResource(R.drawable.ic_close_white_24dp); ImageView voiceIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_voice_btn); voiceIcon.setImageResource(R.drawable.ic_settings_voice_white_24dp); //searchView.setSubmitButtonEnabled(true); // to enable submit button ImageView b = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_button); b.setImageResource(R.drawable.ic_search_white_24dp); //to change submit button icon ImageView searchIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_mag_icon); searchIcon.setImageResource(R.drawable.ic_search_white_24dp); switch (currentTab) { case 0: MenuItem miMap = menu.findItem(R.id.id_action_map); miMap.setVisible(false); break; case 1: MenuItem miSearch = menu.findItem(R.id.id_action_search); miSearch.setVisible(false); break; case 2: MenuItem mi1 = menu.findItem(R.id.id_action_map); mi1.setVisible(false); MenuItem mi2 = menu.findItem(R.id.id_action_search); mi2.setVisible(false); case 3: MenuItem mi3 = menu.findItem(R.id.id_action_map); mi3.setVisible(false); MenuItem mi4 = menu.findItem(R.id.id_action_search); mi4.setVisible(false); break; default: break; } return true; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE IMAGE ROW/* ww w . j a v a 2 s.com*/ * @param att * @param linear * @return */ public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f); ImageView img = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value")); img.setImageResource(context.getResources().getIdentifier(path, null, null)); img.setPadding(0, 3, 0, 3); container_layout.addView(img, value_params); linear.addView(container_layout); return linear; }
From source file:com.example.android.android_me.ui.BodyPartFragment.java
/** * Inflates the fragment layout file and sets the correct resource for the image to display */// ww w . j a v a 2 s. c o m @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the Android-Me fragment layout View rootView = inflater.inflate(R.layout.fragment_body_part, container, false); //Check bundle if (savedInstanceState != null) { mImageIds = savedInstanceState.getIntegerArrayList(IMAGE_ID_LIST); mListIndex = savedInstanceState.getInt(LIST_INDEX); } // Get a reference to the ImageView in the fragment layout final ImageView imageView = (ImageView) rootView.findViewById(R.id.body_part_image_view); // If a list of image ids exists, set the image resource to the correct item in that list // Otherwise, create a Log statement that indicates that the list was not found if (mImageIds != null) { // Set the image resource to the list item at the stored index imageView.setImageResource(mImageIds.get(mListIndex)); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mListIndex < mImageIds.size() - 1) { mListIndex++; } else { mListIndex = 0; } imageView.setImageResource(mImageIds.get(mListIndex)); } }); } else { Log.v(TAG, "This fragment has a null list of image id's"); } // Return the rootView return rootView; }
From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java
private void initImage(List<String> imgUrls) { if (imgUrls == null || imgUrls.size() <= 0) return;//ww w .ja v a 2 s .com int size = imgUrls.size(); if (size > 4)// 4 size = 4; Rect r = new Rect(); et_code.getGlobalVisibleRect(r); int width = r.right - r.left; int singWidth = width / size; int imgWidth = DisplayUtil.dip2px(70, BaseUtils.getDensity()); int imgHeight = DisplayUtil.dip2px(30, BaseUtils.getDensity()); double l = singWidth / (double) imgWidth; if (l <= 1) { imgWidth = singWidth; } else { l = Math.round(l * 100) * 0.01d;// ?2?? imgWidth *= l; imgHeight *= l; } for (int i = 0; i < size; i++) { // ? 105*45 final ImageView img = new ImageView(this.getApplicationContext()); img.setLayoutParams(new LayoutParams(imgWidth, imgHeight)); img.setImageResource(BaseUtils.getResourceValue("drawable", "oasisgames_sdk_payway_mob_epin")); ImageRequest iq = new ImageRequest(imgUrls.get(i), new Response.Listener<Bitmap>() { @Override public void onResponse(final Bitmap arg0) { if (arg0 == null) return; img.setImageBitmap(arg0); img.postInvalidate(); } }, imgWidth, // ??? imgHeight, Config.ARGB_8888, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { setWaitScreen(false); } }); iq.setRetryPolicy(new DefaultRetryPolicy(60000, 2, 1)); ApplicationContextManager.getInstance().getVolleyRequestQueue().add(iq); ll_images.addView(img); } if (ll_images.getChildCount() > 0) { ll_images.setVisibility(View.VISIBLE); } }
From source file:com.mZone.epro.common.view.SlidingTabLayout.java
private void changeTabWidgetView(int tabIndex) { if (mTabViewLayoutId != 0) { for (int i = 0; i < tabViewArray.size(); i++) { View tabView = tabViewArray.get(i); TextView tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); if (mTabViewLayoutId == R.layout.launch_home_fragment_tabhost_tabwidget) { ImageView iconView = (ImageView) tabView.findViewById(R.id.tabwidget_imageview); if (i == tabIndex) { iconView.setImageResource(mCustomTabDelegate.getIconId(i, 1)); tabTitleView.setTextColor(mTabStrip.getCustomTabColorizer().getIndicatorColor(i)); } else { iconView.setImageResource(mCustomTabDelegate.getIconId(i, 0)); tabTitleView.setTextColor(Color.GRAY); }//from ww w.j av a 2s . c o m } } } }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE IMAGE ROW/*from w ww .j ava2 s . c om*/ * @param att * @param linear * @return */ public LinearLayout getDoubleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img1 = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value1")); img1.setImageResource(context.getResources().getIdentifier(path, null, null)); img1.setPadding(0, 3, 0, 3); container_layout.addView(img1, value_one_params); LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img2 = new ImageView(context); path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value2")); img2.setImageResource(context.getResources().getIdentifier(path, null, null)); img2.setPadding(0, 3, 0, 3); container_layout.addView(img2, value_two_params); linear.addView(container_layout); return linear; }
From source file:com.android.browser.GearsBaseDialog.java
public void setupDialog(TextView message, ImageView icon) { message.setText(R.string.unrecognized_dialog_message); icon.setImageResource(R.drawable.ic_dialog_menu_generic); message.setVisibility(View.VISIBLE); }
From source file:mobisocial.musubi.objects.FileObj.java
@Override public void render(Context context, View frame, DbObjCursor obj, boolean allowInteractions) { JSONObject json = obj.getJson();/* w w w . j a va 2s . c o m*/ String fname = ""; String mimetype = "application/octet-stream"; int iconid = R.drawable.icon_default; try { fname = json.getString(OBJ_FILENAME); mimetype = json.getString(CorralDownloadClient.OBJ_MIME_TYPE); iconid = getIconid(fname, mimetype); } catch (JSONException e) { e.printStackTrace(); } ImageView imageView = (ImageView) ((ViewGroup) frame).getChildAt(0); TextView valueTV = (TextView) ((ViewGroup) frame).getChildAt(1); imageView.setImageResource(iconid); String ftype = getDisplayFileType(fname, mimetype); valueTV.setText(ftype + " File: \"" + fname + "\"."); }
From source file:com.friedran.appengine.dashboard.gui.DashboardLoadFragment.java
private void updateChartImage(View chartView, Bitmap image, boolean animate) { ImageView chartImageView = (ImageView) chartView.findViewById(R.id.load_chart_image); if (image != null) { chartImageView.setImageBitmap(image); } else {// ww w . j av a 2 s .com chartImageView.setImageResource(android.R.color.transparent); Toast.makeText(mActivity, "Failed downloading charts, please make sure you have Internet connectivity and try refreshing", 2000).show(); } ViewSwitcher viewSwitcher = (ViewSwitcher) chartView.findViewById(R.id.load_chart_switcher); if (viewSwitcher.getDisplayedChild() != 1) { if (animate) { viewSwitcher.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.fadein)); } else viewSwitcher.setAnimation(null); viewSwitcher.showNext(); } // Mark the refresh UI as complete once anyone of the charts has been loaded. mPullToRefreshAttacher.setRefreshComplete(); }