List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:ca.marklauman.dominionpicker.CardAdapter.java
/** Binds the contents of the Cursor to View elements * provided by this adapter. When a value is bound * by this method, it returns {@code true}, so * that no other binding is performed. If it * returns false, the value is bound by the default * SimpleCursorAdapter methods.// ww w .j a v a 2 s . c om * @param view the view to bind the data to. * @param cursor the cursor to get the data from * (it has been moved to the appropriate position * for this row). * @param columnIndex the index of the column * that is being bound right now. * @return {@code true} if that column was bound to * the view, {@code false} otherwise. */ @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (col_cost == columnIndex || col_gold == columnIndex || col_vict == columnIndex) { if ("0".equals(cursor.getString(columnIndex))) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return false; } else if (col_potion == columnIndex) { if (1 > cursor.getInt(columnIndex)) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return true; } else if (col_expansion == columnIndex) { String val = cursor.getString(col_expansion); ImageView v = (ImageView) view; v.setContentDescription(val); Integer icon_id = exp_icons.get(val); if (icon_id == null) icon_id = R.drawable.ic_set_unknown; v.setImageResource(icon_id); return true; } else if (col_buy == columnIndex) { String res = ""; String val = cursor.getString(col_buy); if (!"0".equals(val)) res += ", +" + val + " buy"; val = cursor.getString(col_draw); if (!"0".equals(val)) res += ", +" + val + " card"; val = cursor.getString(col_act); if (!"0".equals(val)) res += ", +" + val + " action"; if (0 != col_gold && 0 != col_vict && res.length() > 2) res = res.substring(2); if ("".equals(res)) view.setVisibility(View.GONE); else { view.setVisibility(View.VISIBLE); TextView v = (TextView) view; v.setText(res); } return true; } else if (col_desc == columnIndex) { String desc = cursor.getString(columnIndex); if ("".equals(desc)) { view.setVisibility(View.GONE); return true; } view.setVisibility(View.VISIBLE); return false; } else if (col_id == columnIndex) { TextView v = (TextView) view; if (yw_bane != cursor.getLong(col_id)) v.setVisibility(View.GONE); else v.setVisibility(View.VISIBLE); return true; } return false; }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mission_planner); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_mission_planner); if (savedInstanceState == null) { // Load saved missionData if available. try {// w ww. ja va 2 s. c o m FileInputStream inStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "MissionData"); ObjectInputStream objectInStream = new ObjectInputStream(inStream); int count = objectInStream.readInt(); for (int i = 0; i < count; i++) missionData.add((MissionData) objectInStream.readObject()); objectInStream.close(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the list is empty, add the default planet if (missionData.size() == 0) { missionData = setFirstMissionData(); } } else { missionData = savedInstanceState.getParcelableArrayList("key"); } mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground); mListView = (ListView) findViewById(R.id.list); tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV); mAdapter = new StableArrayAdapter(this, missionData, mTouchListener); // add the newDestination button as a footer below the listview ImageView newDestination = new ImageView(this); newDestination.setImageResource(R.drawable.ic_plus); mListView.addFooterView(newDestination); newDestination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use if (missionData.size() < 1) { possibleIconState = 1; } Intent intent = new Intent(MissionPlanner.this, MissionDestination.class); intent.putExtra("possibleIconState", possibleIconState); intent.putExtra("isNewItem", true); // Places the result as a new item in the listview startActivityForResult(intent, 0); } }); mListView.setAdapter(mAdapter); }
From source file:com.cleanwiz.applock.ui.activity.AppLockActivity.java
private void initPoints(int pagers) { pLayout.removeAllViews();//from www.j av a 2s.c o m points = new ArrayList<ImageView>(); int maxW = ScreenUtil.dip2px(mContext, 24); int width = Math.min(maxW, pLayout.getWidth() / pagers); int height = ScreenUtil.dip2px(mContext, 16); for (int i = 0; i < pagers; i++) { ImageView iv = new ImageView(mContext); iv.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height); if (i == 0) { iv.setImageResource(R.drawable.pager_point_white); } else { iv.setImageResource(R.drawable.pager_point_green); } pLayout.addView(iv, lp); points.add(iv); } }
From source file:ac.robinson.ticqr.TicQRActivity.java
private void addTickHighlight(TickBoxHolder tickBox) { int tickIcon = R.drawable.ic_highlight_tick; Drawable tickDrawable = getResources().getDrawable(tickIcon); ImageView tickHighlight = new ImageView(TicQRActivity.this); tickHighlight.setImageResource(tickIcon); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.leftMargin = mImageView.getLeft() + Math.round(tickBox.imagePosition.x) - (tickDrawable.getIntrinsicWidth() / 2); layoutParams.topMargin = mImageView.getTop() + Math.round(tickBox.imagePosition.y) - (tickDrawable.getIntrinsicHeight() / 2); ((RelativeLayout) findViewById(R.id.tick_highlight_holder)).addView(tickHighlight, layoutParams); tickHighlight.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulse)); tickHighlight.setOnClickListener(mTickClickListener); tickHighlight.setTag(tickBox);/*from w w w . jav a2s .co m*/ }
From source file:com.google.samples.apps.topeka.adapter.CategoryAdapter.java
private void setCategoryIcon(Category category, ImageView icon) { final int categoryImageResource = mResources.getIdentifier(ICON_CATEGORY + category.getId(), DRAWABLE, mPackageName);/* ww w . ja v a 2 s. co m*/ final boolean solved = category.isSolved(); if (solved) { Drawable solvedIcon = loadSolvedIcon(category, categoryImageResource); icon.setImageDrawable(solvedIcon); } else { icon.setImageResource(categoryImageResource); } }
From source file:com.layer.atlas.AtlasMessageComposer.java
private void addAttachmentMenuItem(AttachmentSender sender) { LayoutInflater inflater = LayoutInflater.from(getContext()); LinearLayout menuLayout = (LinearLayout) mAttachmentMenu.getContentView(); View menuItem = inflater.inflate(R.layout.atlas_message_composer_attachment_menu_item, menuLayout, false); ((TextView) menuItem.findViewById(R.id.title)).setText(sender.getTitle()); menuItem.setTag(sender);/*from www . jav a 2 s .c om*/ menuItem.setOnClickListener(new OnClickListener() { public void onClick(View v) { mAttachmentMenu.dismiss(); ((AttachmentSender) v.getTag()).requestSend(); } }); if (sender.getIcon() != null) { ImageView iconView = ((ImageView) menuItem.findViewById(R.id.icon)); iconView.setColorFilter(getResources().getColor(R.color.atlas_cell_attachment_title), PorterDuff.Mode.MULTIPLY); iconView.setImageResource(sender.getIcon()); iconView.setVisibility(VISIBLE); Drawable d = DrawableCompat.wrap(iconView.getDrawable()); DrawableCompat.setTint(d, getResources().getColor(R.color.atlas_icon_enabled)); } menuLayout.addView(menuItem); }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.view_zenoss_device_fragment, container, false); Typeface titlesTypeFace = Typeface.create("sans-serif-light", Typeface.BOLD); deviceTitle = (TextView) rootView.findViewById(R.id.DeviceTitle); deviceTitle.setTypeface(titlesTypeFace); loadAverageGraphView = (ImageView) rootView.findViewById(R.id.loadAverageGraph); CPUGraphView = (ImageView) rootView.findViewById(R.id.CPUGraph); MemoryGraphView = (ImageView) rootView.findViewById(R.id.MemoryGraph); snmpAgent = (TextView) rootView.findViewById(R.id.snmpAgent); snmpAgent.setTypeface(titlesTypeFace); snmpContact = (TextView) rootView.findViewById(R.id.snmpContact); snmpContact.setTypeface(titlesTypeFace); snmpLocation = (TextView) rootView.findViewById(R.id.snmpLocation); snmpLocation.setTypeface(titlesTypeFace); Uptime = (TextView) rootView.findViewById(R.id.uptime); Uptime.setTypeface(titlesTypeFace);//from w w w. ja v a 2 s .com MemoryRAM = (TextView) rootView.findViewById(R.id.memory_ram); MemoryRAM.setTypeface(titlesTypeFace); MemorySwap = (TextView) rootView.findViewById(R.id.memory_swap); MemorySwap.setTypeface(titlesTypeFace); LastCollected = (TextView) rootView.findViewById(R.id.lastCollected); LastCollected.setTypeface(titlesTypeFace); hsv = (HorizontalScrollView) rootView.findViewById(R.id.horizontalScrollView); try { ImageView deviceRepImg = ((ImageView) rootView.findViewById(R.id.deviceRepImg)); deviceRepImg.setScaleType(ImageView.ScaleType.CENTER_CROP); Random r = new Random(); deviceRepImg.setImageResource(mThumbIds[r.nextInt(mThumbIds.length)]); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "ImageRand", e); } return rootView; }
From source file:c.neo.placas_validator.LicenseDataActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_license_data); /*/*from w w w .jav a 2 s. c om*/ ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); */ // Creacion del mensaje de espera dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.wait_label)); dialog.setTitle(getString(R.string.gettingdata_label)); Intent intent = getIntent(); licenseID = intent.getStringExtra("LICENSE_ID"); idEntidadImagen = intent.getStringExtra("ENTIDAD_ID"); //String nombreRecursoPolicial = "dir_"+indice_policial; /* int logoid = this.getResources().getIdentifier(nombreRecursoPolicial.toLowerCase(), "drawable", this.getPackageName()); ImageView logo = null; logo = (ImageView)findViewById(R.id.idEntidadImagen); logo.setImageResource(idEntidadImagen); logo = (ImageView)findViewById(R.id.escudo_rd); logo.setImageResource(logoid); */ ImageView logo = null; logo = (ImageView) findViewById(R.id.image_photo); int logoid = this.getResources().getIdentifier(idEntidadImagen, "drawable", this.getPackageName()); logo.setImageResource(logoid); TextView text = (TextView) findViewById(R.id.license_number); text.setText("" + licenseID); /* slidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.slidingpanelayout); //slidingPaneLayout.setSliderFadeColor(android.graphics.Color.parseColor("#C68A34")); slidingPaneLayout.setParallaxDistance(60); slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override public void onPanelSlide(View view, float v) { //Log.d(TAG, "onPanelSlide " + view.getId()); } @Override public void onPanelOpened(View view) { switch (view.getId()) { case R.id.sliding_b: Log.d(TAG, "onPanelOpened B"); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); break; default: break; } } @Override public void onPanelClosed(View view) { switch (view.getId()) { case R.id.sliding_b: Log.d(TAG, "onPanelClosed B"); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); break; default: break; } } }); */ MiTarea obtenerDatos = new MiTarea(licenseID); obtenerDatos.execute(); }
From source file:com.sutromedia.android.core.PhotoActivity.java
private void setImageView(View view, int resourceId, int index, Integer[] licences) { ImageView image = (ImageView) view.findViewById(resourceId); if (index < licences.length) { setVisibility(view, resourceId, true); image.setImageResource(getLicenceBitmap(licences[index])); } else {/*from ww w.j av a 2 s . c o m*/ setVisibility(view, resourceId, false); image.setImageDrawable(null); } }
From source file:com.sunho.nating.fragments.DetailPlaceFragment.java
/** * Bind the views inside of parent with the fragment arguments. * * @param parent The parent of views to bind. *//*from w w w . ja v a 2 s. com*/ private void bind(View parent) { Bundle args = getArguments(); if (args == null) { return; } ImageView image = (ImageView) parent.findViewById(R.id.image); image.setImageResource(args.getInt(ARG_RESOURCE_ID)); TextView title = (TextView) parent.findViewById(R.id.title); title.setText(args.getString(ARG_TITLE)); }