List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.citious.converfit.Contenedores.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from ww w . ja v a 2 s . c o m*/ ImageView tabImageView = null; if (mTabViewLayoutId != 0) { // HAS TO BE SET FOR THE MOMENT! // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabImageView = (ImageView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabImageView == null && ImageView.class.isInstance(tabView)) { tabImageView = (ImageView) tabView; } int resourceId; if (i == mViewPager.getCurrentItem()) { resourceId = imageResSelected[i]; mOldPosition = i; } else { resourceId = imageResId[i]; } tabImageView.setImageResource(resourceId); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } /*for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, mTabStrip, false); ImageView iconImageView = (ImageView) tabView.findViewById(R.id.tab_layout_icon); //iconImageView.setImageDrawable(getContext().getResources().getDrawable(getIconResourceArray()[i])); iconImageView.setImageResource(getIconResourceArray()[i]); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); }*/ /* for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); } */ }
From source file:com.bofsoft.laio.laiovehiclegps.Fragment.BaiduMapFragment.java
private void addOverlay(GPSInfoData gpsInfoData) {//marker ?? ? LatLng llA = new LatLng(gpsInfoData.Latitude, gpsInfoData.Longitude); // GPSGPS?????? CoordinateConverter converter = new CoordinateConverter(); converter.from(CoordinateConverter.CoordType.GPS); // sourceLatLng??? converter.coord(llA);/*from w w w .j a va2 s . c o m*/ // desLatLng = converter.convert(); LatLng tmpLL = converter.convert(); View v_temp = LayoutInflater.from(getActivity()).inflate(R.layout.map_marker, null);// TextView tv_temp = (TextView) v_temp.findViewById(R.id.tv_marker);//?textview ImageView img_temp = (ImageView) v_temp.findViewById(R.id.iv_marker);//?imageview tv_temp.setText(gpsInfoData.License);//? if (gpsInfoData.Status == 0) { img_temp.setImageResource(imgIds[0]);//marker bitmap = BitmapFactory.decodeResource(getResources(), imgIds[0]); } else { img_temp.setImageResource(imgIds[2]);//marker bitmap = BitmapFactory.decodeResource(getResources(), imgIds[2]); } Matrix matrix = new Matrix(); img_temp.setScaleType(ImageView.ScaleType.MATRIX); //required matrix.postScale(1, 1); //ImageViewImage int dw = bitmap.getWidth(); int dh = bitmap.getHeight(); matrix.postRotate((float) gpsInfoData.Direction, (float) dw / 2, (float) dh / 2);// img_temp.setImageMatrix(matrix); bd_temp = BitmapDescriptorFactory.fromView(v_temp);//?marker MarkerOptions oo = new MarkerOptions().position(tmpLL).icon(bd_temp).anchor(0.5f, 1.0f).zIndex(15); Marker mMarkerA = (Marker) (mBaiduMap.addOverlay(oo)); Bundle bundle = new Bundle(); bundle.putString("License", gpsInfoData.getLicense()); mMarkerA.setExtraInfo(bundle); }
From source file:com.nnm.smsviet.MessageListActivity.java
/** * Show {@link Contact}'s photo.//from w w w .j av a 2s . c om * * @param contact * {@link Contact} */ private void setContactIcon(final Contact contact) { if (contact == null) { Log.w(TAG, "setContactIcon(null)"); this.showContactItem = false; return; } final String name = contact.getName(); this.showContactItem = this.showPhoto && name != null; if (this.contactItem == null) { Log.w(TAG, "setContactIcon: contactItem == null"); return; } if (!this.needContactUpdate) { Log.i(TAG, "skip setContactIcon()"); return; } if (this.showPhoto && name != null) { // photo ImageView ivPhoto = (ImageView) this.findViewById(R.id.photo); if (ivPhoto == null) { ivPhoto = (ImageView) this.contactItem.getActionView().findViewById(R.id.photo); } if (ivPhoto == null) { Log.w(TAG, "ivPhoto == null"); } else { ivPhoto.setImageDrawable(contact.getAvatar(this, this.defaultContactAvatar)); ivPhoto.setOnClickListener(WRAPPER.getQuickContact(this, ivPhoto, contact.getLookUpUri(this.getContentResolver()), 2, null)); } // presence ImageView ivPresence = (ImageView) this.findViewById(R.id.presence); if (ivPresence == null) { ivPresence = (ImageView) this.contactItem.getActionView().findViewById(R.id.presence); } if (ivPresence == null) { Log.w(TAG, "ivPresence == null"); } else { if (contact.getPresenceState() > 0) { ivPresence.setImageResource(Contact.getPresenceRes(contact.getPresenceState())); ivPresence.setVisibility(View.VISIBLE); } else { ivPresence.setVisibility(View.INVISIBLE); } } } this.contactItem.setVisible(this.showContactItem); this.needContactUpdate = false; }
From source file:com.openerp.addons.messages.Message.java
private boolean markAsTodo(HashMap<Integer, Integer> msg_pos, final boolean flag) { boolean res = false; final int img[] = new int[] { R.drawable.ic_action_unstarred, R.drawable.ic_action_starred }; for (int key : msg_pos.keySet()) { final int pos = msg_pos.get(key); OEArgsHelper args = new OEArgsHelper(); args.addArg(key);//from www .jav a2 s . c om if (markAsTodo(args, flag)) { listAdapter.updateRows(getRowForMessage(key), pos, "starred"); scope.context().runOnUiThread(new Runnable() { public void run() { ImageView imgStarred = (ImageView) lstview.getChildAt(pos) .findViewById(R.id.imgMessageStarred); imgStarred.setImageResource((flag) ? img[1] : img[0]); imgStarred.invalidate(); } }); } } return res; }
From source file:com.kjsaw.alcosys.ibacapp.IBAC.java
private void InitializeAllServices() { if (_isConfiguringPhone) { return;/*from w w w . ja va 2s . c o m*/ } if (!_bluetoothAdapter.isEnabled()) { // bluetooth is not enabled so wait until its enabled...then call this method again _isConfiguringPhone = true; Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { _iBACservice._messageProcessor.RegisterStateListener(this); if (_iBACservice.getState() == 0 && _bluetoothAdapter.isEnabled()) { final Intent serverIntent = new Intent(this, BluetoothIBACDiscovery.class); //BluetoothIBACDiscoveryLTE _btDiscovery = new Runnable() { public void run() { startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE); } }; _handler.postDelayed(_btDiscovery, 1500); // 3000 // change to the blue logo ImageView mAlcoLogo = (ImageView) findViewById(R.id.mti); mAlcoLogo.setImageResource(R.drawable.alcogreenbg); _conversationArrayAdapter.clear(); _conversationArrayAdapterBottom.clear(); _conversationArrayAdapter.add(getResources().getString(R.string.turn_on_ibac)); } // Take an extra look on this if (_iBACservice != null) { if (_iBACservice.getState() == BluetoothIBACService.STATE_NONE) { _iBACservice.start(); } } } }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
/** * Helper to create earlier or later adapter. * @param resource the image resource to show in the list * @return a prepared adapter//from w ww. j a va 2 s.c om */ private SimpleAdapter createEarlierLaterAdapter(int resource) { ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); map.put("image", resource); list.add(map); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.earlier_later_routes_row, new String[] { "image" }, new int[] { R.id.earlier_later, }); adapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { switch (view.getId()) { case R.id.earlier_later: ImageView imageView = (ImageView) view; imageView.setImageResource((Integer) data); return true; } return false; } }); return adapter; }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_activity, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); try {//from ww w . j a v a 2 s . c om searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Assumes current activity is the searchable activity searchView.setIconifiedByDefault(true); // Do not iconify the widget; expand it by default int searchImgId = getResources().getIdentifier("android:id/search_button", null, null); ImageView view = (ImageView) searchView.findViewById(searchImgId); view.setImageResource(settings.theme == AppSettings.THEME_LIGHT ? R.drawable.ic_action_search_light : R.drawable.ic_action_search_dark); } catch (Exception e) { } try { Field searchField = SearchView.class.getDeclaredField("mCloseButton"); searchField.setAccessible(true); closeBtn = (ImageView) searchField.get(searchView); int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); EditText searchPlate = (EditText) searchView.findViewById(searchPlateId); searchPlate.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (!b) { closeBtn.callOnClick(); } } }); } catch (Exception e) { } return super.onCreateOptionsMenu(menu); }
From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java
private void populateTabStrip() { final TabAdapter adapter = (TabAdapter) viewPager.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { ImageView tabIconView = null; final View tabView = (tabProvider == null) ? createDefaultTabView(adapter.getDrawableId(i)) : tabProvider.createTabView(tabStrip, i, adapter); if (tabView == null) { throw new IllegalStateException("tabView is null."); }/*from ww w .j a v a 2 s. c om*/ if (distributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (ImageView.class.isInstance(tabView)) { tabIconView = (ImageView) tabView; } if (tabIconView != null) { tabIconView.setImageResource(adapter.getDrawableId(i)); if (viewPager.getCurrentItem() == i) { tabIconView.setSelected(true); } } if (internalTabClickListener != null) { tabView.setOnClickListener(internalTabClickListener); } if (i == 1) { View view = LayoutInflater.from(getContext()).inflate(R.layout.counter, tabStrip, false); FrameLayout counterLayout = (FrameLayout) view.findViewById(R.id.counter_layout); messageBackground = (ImageView) view.findViewById(R.id.message_background); counter = (TextView) view.findViewById(R.id.counter); counter.setText(String.valueOf(messageCount)); ImageView imageView = new ImageView(getContext()); imageView.setImageResource(adapter.getDrawableId(i)); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); counterLayout.addView(imageView, 0); if (internalTabClickListener != null) { view.setOnClickListener(internalTabClickListener); } if (messageCount > 0) { messageBackground.setVisibility(VISIBLE); counter.setVisibility(VISIBLE); } else { messageBackground.setVisibility(GONE); counter.setVisibility(GONE); } tabStrip.addView(view); } else { tabStrip.addView(tabView); } if (i == viewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.abewy.android.apps.klyph.app.MainActivity.java
private void refreshUserPics() { ProfileImageView picView = (ProfileImageView) findViewById(R.id.user_profile_picture); ImageView coverView = (ImageView) findViewById(R.id.user_cover_picture); picView.disableBorder();/*w ww. j a v a 2s . c om*/ ImageLoader.display(picView, userPicUrl, KlyphUtil.getProfilePlaceHolder(picView.getContext())); String userCoverUrl = userCover != null ? userCover.getSource() : null; if (userCoverUrl != null && userCoverUrl.length() > 0) { UserCoverImageView userCoverImageView = (UserCoverImageView) coverView; userCoverImageView.setOffset(userCover.getOffset_y()); ImageLoader.display(coverView, userCoverUrl, R.drawable.picture_place_holder_square_dark); } else { coverView.setImageResource(R.drawable.picture_place_holder_square_dark); } }
From source file:com.android.tv.settings.dialog.DialogFragment.java
public void setIcon(int iconResourceId) { mIconResourceId = iconResourceId;/*from w w w . jav a 2 s . co m*/ View v = getView(); if (v != null) { final ImageView iconImageView = (ImageView) v.findViewById(R.id.icon); if (iconImageView != null) { if (iconResourceId != 0) { iconImageView.setImageResource(iconResourceId); iconImageView.setVisibility(View.VISIBLE); updateViewSize(iconImageView); } } } }