List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.msted.lensrocket.activities.RocketsListActivity.java
private void startCountdownTimer(final Rocket rocket) { int position = mLensRocketService.getLocalRockets().indexOf(rocket); if (rocket == null) LensRocketLogger.i(TAG, "Rocket is null"); LensRocketLogger.i(TAG, "Position: " + position); if (mLvRockets == null) LensRocketLogger.i(TAG, "mlvrockets is null"); View view = mLvRockets.getChildAt(position); final TextView lblTime = (TextView) view.findViewById(R.id.lblTime); //Only start a countdown if we haven't already if (lblTime.getText().equals("")) { final ImageView imgIndicator = (ImageView) view.findViewById(R.id.imgIndicator); final TextView lblInstructions = (TextView) view.findViewById(R.id.lblInstructions); int timeToLive = rocket.getTimeToLive(); lblTime.setText(timeToLive + ""); new CountDownTimer(timeToLive * 1000, 1000) { public void onTick(long millisUntilFinished) { lblTime.setText(millisUntilFinished / 1000 + ""); }/*www . j a v a 2 s . com*/ public void onFinish() { imgIndicator.setImageResource(R.drawable.rocket_seen); lblTime.setText(R.string.empty_string); lblInstructions.setText(R.string.instructions_seen_rocket); rocket.setHasUserSeen(true); if (mViewingDialog.isShowing()) mViewingDialog.dismiss(); if (mBitmapHolder != null && !mBitmapHolder.isRecycled()) mBitmapHolder.recycle(); if (mVideoFile != null) mVideoFile.delete(); } }.start(); } }
From source file:de.geeksfactory.opacclient.frontend.ResultsAdapter.java
@Override public View getView(int position, View contentView, ViewGroup viewGroup) { View view;/*from w w w .jav a2 s .c o m*/ // position always 0-7 if (objects.get(position) == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false); return view; } SearchResult item = objects.get(position); if (contentView == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false); } else { view = contentView; } TextView tv = (TextView) view.findViewById(R.id.tvResult); tv.setText(Html.fromHtml(item.getInnerhtml())); ImageView ivType = (ImageView) view.findViewById(R.id.ivType); PreferenceDataSource pds = new PreferenceDataSource(getContext()); ConnectivityManager connMgr = (ConnectivityManager) getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (item.getCoverBitmap() != null) { ivType.setImageBitmap(BitmapUtils.bitmapFromBytes(item.getCoverBitmap())); ivType.setVisibility(View.VISIBLE); ivType.setPadding(0, 0, 0, 0); } else if ((pds.isLoadCoversOnDataPreferenceSet() || !ConnectivityManagerCompat.isActiveNetworkMetered(connMgr)) && item.getCover() != null) { LoadCoverTask lct = new LoadCoverTask(ivType, item); lct.execute(); ivType.setImageResource(R.drawable.ic_loading); ivType.setVisibility(View.VISIBLE); ivType.setPadding(0, 0, 0, 0); } else if (item.getType() != null && item.getType() != MediaType.NONE) { ivType.setImageResource(getResourceByMediaType(item.getType())); ivType.setVisibility(View.VISIBLE); ivType.setPadding(padding8dp, padding8dp, padding8dp, padding8dp); } else { ivType.setVisibility(View.INVISIBLE); } ImageView ivStatus = (ImageView) view.findViewById(R.id.ivStatus); if (item.getStatus() != null) { ivStatus.setVisibility(View.VISIBLE); switch (item.getStatus()) { case GREEN: ivStatus.setImageResource(R.drawable.status_light_green_check); break; case RED: ivStatus.setImageResource(R.drawable.status_light_red_cross); break; case YELLOW: ivStatus.setImageResource(R.drawable.status_light_yellow_alert); break; case UNKNOWN: ivStatus.setVisibility(View.INVISIBLE); break; } } else { ivStatus.setVisibility(View.GONE); } return view; }
From source file:com.corporatetaxi.TaxiArrived_Acitivity.java
public void caceldialog() { AlertDialog.Builder builder = new AlertDialog.Builder(TaxiArrived_Acitivity.this); AppPreferences.setApprequestTaxiScreen(TaxiArrived_Acitivity.this, false); LayoutInflater inflater = getLayoutInflater(); View header = inflater.inflate(R.layout.dialog_heading, null); TextView textView = (TextView) header.findViewById(R.id.text); ImageView icon = (ImageView) header.findViewById(R.id.icon); icon.setImageResource(R.drawable.ic_launcher); textView.setText("Taxi Has Arrived"); builder.setCustomTitle(header);/* w w w. j a va 2 s .com*/ builder.setCancelable(false); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.show(); }
From source file:fm.libre.droid.LibreDroid.java
public void updateSong() { Song song = libreServiceConn.service.getSong(); final TextView titleText = (TextView) findViewById(R.id.titleText); final TextView artistText = (TextView) findViewById(R.id.artistText); final TextView stationText = (TextView) findViewById(R.id.stationNameText); final ImageView albumImage = (ImageView) findViewById(R.id.albumImage); final ImageButton playPauseButton = (ImageButton) findViewById(R.id.playPauseButton); playPauseButton.setImageResource(R.drawable.pause); titleText.setText(song.title);//w w w .j a va 2s . c o m artistText.setText(song.artist); stationText.setText(libreServiceConn.service.getStationName()); if (song.imageURL.length() > 0) { new AlbumImageTask().execute(song.imageURL); } else { albumImage.setImageResource(R.drawable.album); } }
From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java
/** * Method to add to te grid and to the list of movements, but when they are loaded from a file * not when the user press a button//from ww w . j a va 2 s. c o m * @param movement the movement obtained from the stored file */ private void addViewToTheGrid(String movement) { Integer iconId = null; if (movement.equals(RoboPadConstants.STOP_COMMAND)) { iconId = R.drawable.ic_stop_button; } else if (movement.equals(RoboPadConstants.UP_COMMAND)) { iconId = R.drawable.ic_up_button; } else if (movement.equals(RoboPadConstants.DOWN_COMMAND)) { iconId = R.drawable.ic_down_button; } else if (movement.equals(RoboPadConstants.LEFT_COMMAND)) { iconId = R.drawable.ic_left_button; } else if (movement.equals(RoboPadConstants.RIGHT_COMMAND)) { iconId = R.drawable.ic_right_button; } else if (movement.equals(RoboPadConstants.FULL_OPEN_STEP_COMMAND)) { iconId = R.drawable.ic_scheduler_full_open_claw; } else if (movement.equals(RoboPadConstants.OPEN_STEP_COMMAND)) { iconId = R.drawable.ic_scheduler_open_claw; } else if (movement.equals(RoboPadConstants.CLOSE_STEP_COMMAND)) { iconId = R.drawable.ic_scheduler_close_claw; } else if (movement.equals(RoboPadConstants.CHARGE_COMMAND)) { iconId = R.drawable.charge_button; } else if (movement.equals(RoboPadConstants.COMMAND_1)) { iconId = R.drawable.comand_button_1; } else if (movement.equals(RoboPadConstants.COMMAND_2)) { iconId = R.drawable.comand_button_2; } else if (movement.equals(RoboPadConstants.COMMAND_3)) { iconId = R.drawable.comand_button_3; } else if (movement.equals(RoboPadConstants.COMMAND_4)) { iconId = R.drawable.comand_button_4; } else if (movement.equals(RoboPadConstants.COMMAND_5)) { iconId = R.drawable.comand_button_5; } else if (movement.equals(RoboPadConstants.COMMAND_6)) { iconId = R.drawable.comand_button_6; } if (iconId != null) { ImageView view = (ImageView) ImageView.inflate(getActivity().getBaseContext(), R.layout.grid_view_item_layout, null); view.setImageResource(iconId); gridView.addView(view); scheduledControls.add(movement); } }
From source file:com.ffmpeger.card.ui.BaseNaviActivity.java
private View makeNavDrawerItem(final int itemId, ViewGroup container) { boolean selected = getSelfNavDrawerItem() == itemId; int layoutToInflate = 0; if (itemId == NAVDRAWER_ITEM_SEPARATOR) { layoutToInflate = R.layout.navdrawer_separator; } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) { layoutToInflate = R.layout.navdrawer_separator; } else {//w ww .j a v a2 s . c om layoutToInflate = R.layout.navdrawer_item; } View view = getLayoutInflater().inflate(layoutToInflate, container, false); if (isSeparator(itemId)) { // we are done //UIUtils.setAccessibilityIgnore(view); return view; } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID.length ? NAVDRAWER_ICON_RES_ID[itemId] : 0; int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID.length ? NAVDRAWER_TITLE_RES_ID[itemId] : 0; // set icon and text iconView.setVisibility(iconId > 0 ? View.VISIBLE : View.GONE); if (iconId > 0) { iconView.setImageResource(iconId); } titleView.setText(getString(titleId)); formatNavDrawerItem(view, itemId, selected); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavDrawerItemClicked(itemId); } }); return view; }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
private void addLightsOutButton(LinearLayout root, View v, boolean landscape, boolean empty) { ImageView addMe = new ImageView(mContext); addMe.setLayoutParams(v.getLayoutParams()); addMe.setImageResource( empty ? R.drawable.ic_sysbar_lights_out_dot_large : R.drawable.ic_sysbar_lights_out_dot_small); addMe.setScaleType(ImageView.ScaleType.CENTER); addMe.setVisibility(empty ? View.INVISIBLE : View.VISIBLE); if (landscape) root.addView(addMe, 0);/*from w w w .ja va 2s. co m*/ else root.addView(addMe); }
From source file:com.battlelancer.seriesguide.ui.OverviewFragment.java
private void onPopulateShowData(Cursor show) { if (show == null || !show.moveToFirst()) { return;//w w w.ja v a2 s. c om } mShowCursor = show; // set show title in action bar mShowTitle = show.getString(ShowQuery.SHOW_TITLE); ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); actionBar.setTitle(mShowTitle); // status final TextView statusText = (TextView) getView().findViewById(R.id.showStatus); int status = show.getInt(ShowQuery.SHOW_STATUS); if (status == 1) { statusText.setTextColor(getResources().getColor( Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.textColorSgGreen))); statusText.setText(getString(R.string.show_isalive)); } else if (status == 0) { statusText.setTextColor(Color.GRAY); statusText.setText(getString(R.string.show_isnotalive)); } // favorite final ImageView favorited = (ImageView) getView().findViewById(R.id.imageViewFavorite); boolean isFavorited = show.getInt(ShowQuery.SHOW_FAVORITE) == 1; if (isFavorited) { favorited.setImageResource( Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableStar)); } else { favorited.setImageResource( Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableStar0)); } CheatSheet.setup(favorited, isFavorited ? R.string.context_unfavorite : R.string.context_favorite); favorited.setTag(isFavorited); // poster background Utils.loadPosterBackground(getActivity(), mBackgroundImage, show.getString(ShowQuery.SHOW_POSTER)); // air time and network final StringBuilder timeAndNetwork = new StringBuilder(); final long releaseTime = show.getLong(ShowQuery.SHOW_RELEASE_TIME); final String releaseCountry = show.getString(ShowQuery.SHOW_RELEASE_COUNTRY); final String releaseDay = show.getString(ShowQuery.SHOW_RELEASE_DAY); if (!TextUtils.isEmpty(releaseDay) && releaseTime != -1) { String[] values = TimeTools.formatToShowReleaseTimeAndDay(getActivity(), releaseTime, releaseCountry, releaseDay); timeAndNetwork.append(values[1]).append(" ").append(values[0]).append(" "); } final String network = show.getString(ShowQuery.SHOW_NETWORK); if (!TextUtils.isEmpty(network)) { timeAndNetwork.append(getString(R.string.show_on_network, network)); } ((TextView) getActivity().findViewById(R.id.showmeta)).setText(timeAndNetwork.toString()); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
private void SetBulbStatus(boolean started) { ImageView bulb = (ImageView) findViewById(R.id.notification_bulb); bulb.setImageResource(started ? R.drawable.circle_green : R.drawable.circle_none); }
From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java
/** * /*from w w w .ja v a 2s . c o m*/ * @param view */ private void displayResult(View view, LayoutInflater inflater, ViewGroup vg) { /* final Button shareButton = (Button) view.findViewById(R.id.resultButtonShare); if (shareButton != null) shareButton.setEnabled(false); */ //final LinearLayout measurementLayout = (LinearLayout) view.findViewById(R.id.resultMeasurementList); measurementLayout = (LinearLayout) view.findViewById(R.id.resultMeasurementList); measurementLayout.setVisibility(View.GONE); final LinearLayout resultLayout = (LinearLayout) view.findViewById(R.id.result_layout); resultLayout.setVisibility(View.INVISIBLE); final LinearLayout netLayout = (LinearLayout) view.findViewById(R.id.resultNetList); netLayout.setVisibility(View.GONE); final TextView measurementHeader = (TextView) view.findViewById(R.id.resultMeasurement); measurementHeader.setVisibility(View.GONE); final TextView netHeader = (TextView) view.findViewById(R.id.resultNet); netHeader.setVisibility(View.GONE); final TextView emptyView = (TextView) view.findViewById(R.id.infoText); emptyView.setVisibility(View.GONE); final float scale = activity.getResources().getDisplayMetrics().density; final ProgressBar progessBar = (ProgressBar) view.findViewById(R.id.progressBar); if (testResult != null && testResult.length() > 0) { JSONObject resultListItem; try { resultListItem = testResult.getJSONObject(0); openTestUuid = resultListItem.optString("open_test_uuid"); if (graphView != null) { graphView.setOpenTestUuid(openTestUuid); graphView.initialize(graphViewEndTaskListener); } JSONObject testResultItem; try { testResultItem = testResult.getJSONObject(0); if (testResultItem.has("geo_lat") && testResultItem.has("geo_long") && !hasMap) { hasMap = true; if (dataChangedListener != null) { dataChangedListener.onChange(false, true, "HAS_MAP"); } notifyDataSetChanged(); } else if (!testResultItem.has("geo_lat") && !testResultItem.has("geo_long") && hasMap) { System.out.println("hasMap = " + hasMap); hasMap = false; if (dataChangedListener != null) { dataChangedListener.onChange(true, false, "HAS_MAP"); } notifyDataSetChanged(); } } catch (JSONException e) { hasMap = false; e.printStackTrace(); } if (completeListener != null) { completeListener.onComplete(OnCompleteListener.DATA_LOADED, this); } final JSONArray measurementArray = resultListItem.getJSONArray("measurement"); final JSONArray netArray = resultListItem.getJSONArray("net"); final int leftRightDiv = Helperfunctions.dpToPx(0, scale); final int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); for (int i = 0; i < measurementArray.length(); i++) { final View measurementItemView = inflater.inflate(R.layout.classification_list_item, vg, false); final JSONObject singleItem = measurementArray.getJSONObject(i); final TextView itemTitle = (TextView) measurementItemView .findViewById(R.id.classification_item_title); itemTitle.setText(singleItem.getString("title")); final ImageView itemClassification = (ImageView) measurementItemView .findViewById(R.id.classification_item_color); itemClassification.setImageResource( Helperfunctions.getClassificationColor(singleItem.getInt("classification"))); itemClassification.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { activity.showHelp(R.string.url_help_result, false); } }); final TextView itemValue = (TextView) measurementItemView .findViewById(R.id.classification_item_value); itemValue.setText(singleItem.getString("value")); measurementLayout.addView(measurementItemView); final View divider = new View(activity); divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); measurementLayout.addView(divider); measurementLayout.invalidate(); } for (int i = 0; i < netArray.length(); i++) { final JSONObject singleItem = netArray.getJSONObject(i); addResultListItem(singleItem.getString("title"), singleItem.optString("value", null), netLayout); } addQoSResultItem(); } catch (final JSONException e) { e.printStackTrace(); } progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); resultLayout.setVisibility(View.VISIBLE); measurementHeader.setVisibility(View.VISIBLE); netHeader.setVisibility(View.VISIBLE); measurementLayout.setVisibility(View.VISIBLE); netLayout.setVisibility(View.VISIBLE); } else { Log.i(DEBUG_TAG, "LEERE LISTE"); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); emptyView.setText(activity.getString(R.string.error_no_data)); emptyView.invalidate(); } }