List of usage examples for android.content.res Resources getDrawable
@Deprecated public Drawable getDrawable(@DrawableRes int id) throws NotFoundException
From source file:jp.ac.anan_nct.TabletInterphone.Fragment.VisiterInteractionFragment.java
private void changeCamera(View view, int interval) { Resources r = getResources(); Drawable camera;/*from ww w . j av a 2s. c o m*/ if (interval < 0) { camera = r.getDrawable(R.drawable.camera_off); cameraStatus = -1; } else if (interval > 0) { camera = r.getDrawable(R.drawable.camera_idle); cameraStatus = 1; } else { camera = r.getDrawable(R.drawable.camera_on); cameraStatus = 0; } ImageView cameraImg = (ImageView) view.findViewById(R.id.camera); cameraImg.setImageDrawable(camera); }
From source file:com.aimfire.intro.IntroductionActivity.java
private void selectDot(int idx) { Resources res = getResources(); for (int i = 0; i < NUM_PAGES; i++) { int drawableId = (i == idx) ? (R.drawable.pager_dot_selected) : (R.drawable.pager_dot_not_selected); Drawable drawable = res.getDrawable(drawableId); dots.get(i).setImageDrawable(drawable); }//www . j a v a2 s . com }
From source file:com.heneryh.aquanotes.ui.controllers.OutletsDataAdapter.java
/** {@inheritDoc} */ @Override//from w w w.j a v a 2 s .c o m public void bindView(View view, Context context, Cursor cursor) { String outletName = cursor.getString(OutletDataViewQuery.NAME); ((TextView) view.findViewById(R.id.outlet_title)).setText(outletName); String deviceId = cursor.getString(OutletDataViewQuery.DEVICE_ID); ((TextView) view.findViewById(R.id.outlet_subtitle)).setText(deviceId); Spinner spinner = (Spinner) view.findViewById(R.id.spin); spinner.setAdapter(adapter); Integer controllerId = cursor.getInt(OutletDataViewQuery.CONTROLLER_ID); spinner.setOnItemSelectedListener(new myOnItemSelectedListener(outletName, controllerId)); // Assign track color to visible block String val = cursor.getString(OutletDataViewQuery.VALUE); final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon1); Resources res = mActivity.getResources(); //// Axx = Auto-On or Auto-Off //// OFF = Manual Off //// ON = Manual On if (val.equalsIgnoreCase("AON")) { iconView.setImageDrawable(res.getDrawable(R.drawable.on)); spinner.setSelection(0); } else if (val.equalsIgnoreCase("AOF")) { iconView.setImageDrawable(res.getDrawable(R.drawable.off)); spinner.setSelection(0); } else if (val.equalsIgnoreCase("OFF")) { iconView.setImageDrawable(res.getDrawable(R.drawable.off)); spinner.setSelection(1); } else if (val.equalsIgnoreCase("ON")) { iconView.setImageDrawable(res.getDrawable(R.drawable.on)); spinner.setSelection(2); } else { iconView.setImageDrawable(new ColorDrawable(Color.BLUE)); } }
From source file:com.ndn.menurandom.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. *//*from w w w . j a va2 s .c o m*/ private void forceDownload(String url, ImageView imageView) { // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys. if (url == null) { imageView.setImageDrawable(null); return; } if (cancelPotentialDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); DownloadedDrawable downloadedDrawable = null; if (mContext != null) { Resources res = mContext.getResources(); Drawable d = res.getDrawable(mDefaultImageResourceId); if (d instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) d).getBitmap(); downloadedDrawable = new DownloadedDrawable(res, bitmap, task); } } imageView.setImageDrawable(downloadedDrawable); imageView.setMinimumHeight(156); task.execute(url); } }
From source file:jp.ac.anan_nct.TabletInterphone.Fragment.VisiterInteractionFragment.java
private void changeSpeaker(View view) { Resources r = getResources(); Drawable speaker;/*from w w w .j a va 2s .c o m*/ switch (sharedVariable.phoneCallStatus(0)) { case Const.VOICE_CHAT_LISTEN_ONLY: speaker = r.getDrawable(R.drawable.speaker_on); isSpeakerClick = true; break; case Const.INTERACTION_PHONE_CALL_END: speaker = r.getDrawable(R.drawable.speaker_off); isSpeakerClick = false; break; default: speaker = r.getDrawable(R.drawable.speaker_off); break; } ImageView speakerImg = (ImageView) view.findViewById(R.id.speaker); speakerImg.setImageDrawable(speaker); }
From source file:com.commonsware.android.EMusicDownloader.SingleAlbum.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.singlealbum); nameTextView = (TextView) findViewById(R.id.tname); artistTextView = (TextView) findViewById(R.id.tartist); genreTextView = (TextView) findViewById(R.id.tgenre); labelTextView = (TextView) findViewById(R.id.tlabel); genreLayout = (LinearLayout) findViewById(R.id.llgenre); artistLayout = (LinearLayout) findViewById(R.id.llartist); labelLayout = (LinearLayout) findViewById(R.id.lllabel); Resources res = getResources(); if (version < 11) { genreLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); labelLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); artistLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); } else {//from w w w. j a v a2 s. c o m genreLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); labelLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); artistLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); } genreLayout.setFocusable(true); labelLayout.setFocusable(true); artistLayout.setFocusable(true); albumArt = (ImageView) findViewById(R.id.albumart); trackList = (ListView) findViewById(R.id.trklist); ratingBar = (RatingBar) findViewById(R.id.rbar); trackList.setOnItemClickListener(this); reviewsButton = (ImageView) findViewById(R.id.reviewsbutton); //sampleButton=(ImageView)findViewById(R.id.samplebutton); if (vLoaded) { handlerSetContent.sendEmptyMessage(0); if (vArtExists) { albumArt.setImageBitmap(albumArtBitmap); } else { albumArt.setImageResource(R.drawable.noalbum); ; } } }
From source file:com.android.tabcarouseldemo.MainActivity.java
/** * {@inheritDoc}/*from w ww . j a v a2 s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the layout setContentView(R.layout.carousel_container); // Resources final Resources res = getResources(); // Initialize the header final CarouselContainer carousel = (CarouselContainer) findViewById(R.id.carousel_header); // Indicates that the carousel should only show a fraction of the // secondary tab carousel.setUsesDualTabs(false); // Add some text to the labels carousel.setLabel(FIRST_TAB, "Lost in Translation"); carousel.setLabel(SECOND_TAB, "The Prestige"); // Add some images to the tabs carousel.setImageDrawable(FIRST_TAB, res.getDrawable(R.drawable.lost_in_translation)); carousel.setImageDrawable(SECOND_TAB, res.getDrawable(R.drawable.the_prestige)); // The Bundle for the color fragment final Bundle blue = new Bundle(); blue.putInt("color", Color.parseColor("#ff33b5e5")); // Initialize the pager adatper final PagerAdapter pagerAdapter = new PagerAdapter(this); pagerAdapter.add(DummyListFragment.class, new Bundle()); pagerAdapter.add(ColorFragment.class, blue); // Initialize the pager final ViewPager carouselPager = (ViewPager) findViewById(R.id.carousel_pager); // This is used to communicate between the pager and header carouselPager.setOnPageChangeListener(new CarouselPagerAdapter(carouselPager, carousel)); carouselPager.setAdapter(pagerAdapter); }
From source file:com.trungkent.androidviewcollection.tabcarousel.CarouselActivity.java
/** * {@inheritDoc}/*w w w . jav a 2s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the layout setContentView(R.layout.carousel_container); // Resources final Resources res = getResources(); // Initialize the header final CarouselContainer carousel = (CarouselContainer) findViewById(R.id.carousel_header); // Indicates that the carousel should only show a fraction of the // secondary tab carousel.setUsesDualTabs(true); // Add some text to the labels carousel.setLabel(FIRST_TAB, "Lost in Translation"); carousel.setLabel(SECOND_TAB, "The Prestige"); // Add some images to the tabs carousel.setImageDrawable(FIRST_TAB, res.getDrawable(R.drawable.lost_in_translation)); carousel.setImageDrawable(SECOND_TAB, res.getDrawable(R.drawable.the_prestige)); // The Bundle for the color fragment final Bundle blue = new Bundle(); blue.putInt("color", Color.parseColor("#ff33b5e5")); // Initialize the pager adatper final PagerAdapter pagerAdapter = new PagerAdapter(this); pagerAdapter.add(DummyListFragment.class, new Bundle()); pagerAdapter.add(ColorFragment.class, blue); // Initialize the pager final ViewPager carouselPager = (ViewPager) findViewById(R.id.carousel_pager); // This is used to communicate between the pager and header carouselPager.setOnPageChangeListener(new CarouselPagerAdapter(carouselPager, carousel)); carouselPager.setAdapter(pagerAdapter); }
From source file:com.commonsware.android.EMusicDownloader.SingleAlbum.java
/** Called when the activity is first created. */ @Override//ww w .j a va 2 s. co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.singlealbum); version = android.os.Build.VERSION.SDK_INT; Intent myIntent = getIntent(); albumId = myIntent.getStringExtra("keyalbumid"); emusicURL = myIntent.getStringExtra("keyexturl"); album = myIntent.getStringExtra("keyalbum"); artist = myIntent.getStringExtra("keyartist"); thisActivity = this; genreLayout = (LinearLayout) findViewById(R.id.llgenre); artistLayout = (LinearLayout) findViewById(R.id.llartist); labelLayout = (LinearLayout) findViewById(R.id.lllabel); nameTextView = (TextView) findViewById(R.id.tname); artistTextView = (TextView) findViewById(R.id.tartist); genreTextView = (TextView) findViewById(R.id.tgenre); labelTextView = (TextView) findViewById(R.id.tlabel); Resources res = getResources(); if (version < 11) { genreLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); labelLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); artistLayout.setBackgroundDrawable(res.getDrawable(android.R.drawable.list_selector_background)); } else { genreLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); labelLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); artistLayout.setBackgroundResource(R.drawable.list_selector_holo_dark); } genreLayout.setFocusable(true); labelLayout.setFocusable(true); artistLayout.setFocusable(true); albumArt = (ImageView) findViewById(R.id.albumart); reviewsButton = (ImageView) findViewById(R.id.reviewsbutton); //sampleButton=(ImageView)findViewById(R.id.samplebutton); trackList = (ListView) findViewById(R.id.trklist); ratingBar = (RatingBar) findViewById(R.id.rbar); trackList.setOnItemClickListener(this); urlAddress = "http://api.emusic.com/album/info?" + Secrets.apikey + "&albumId=" + albumId + "&include=albumRating,label&imageSize=small"; //Log.d("EMD - ",urlAddress); getInfoFromXML(); }
From source file:com.magicmod.mmweather.MainActivity.java
private void updateWeatherView(WeatherInfo weatherInfo, boolean refreshFragment) { if (weatherInfo == null) { return;//w w w.j a v a 2 s . co m } WeatherProvider provider = mWeatherEngine.getWeatherProvider(); WeatherResProvider res = provider.getWeatherResProvider(); if (refreshFragment) { if (fragments.size() > 0) { ((NextDaysFirstWeatherFragment) mWeatherPagerAdapter.getItem(0)).updateWeather(weatherInfo, res, mContext); ((NextDaysSecondWeatherFragment) mWeatherPagerAdapter.getItem(1)).updateWeather(weatherInfo, res, mContext); } } ArrayList<DayForecast> days = weatherInfo.getDayForecast(); DayForecast today = res.getPreFixedWeatherInfo(mContext, days.get(0)); mCountryTextView.setText(Preferences.getCountryName(mContext)); mTitleCityName.setText(today.getCity()); mCityTextView.setText(today.getCity()); mWeatherSourceTextView.setText(provider.getNameResourceId()); String s = mContext.getResources().getString(R.string.weather_sync_time); s = String.format(s, today.getSynctimestamp()); mSyncTimeTextView.setText(s); mPm25TextView.setText(today.getPM2Dot5Data()); mAqiDataTextView.setText(today.getAQIData()); s = res.getWeek(today, mContext); mTodayWeekTextView.setText(s); s = res.getDay(today) + " " + res.getMonth(today); mTodayMonthTextView.setText(s); mTempTextView.setText(today.getTemperature()); s = mContext.getResources().getString(R.string.weather_humidity); s = String.format(s, today.getHumidity()); mHumidityTextView.setText(s); mWeatherConditionTextView.setText(today.getCondition()); mWindTextView.setText(today.getWindDirection() + " " + today.getWindSpeed()); //Drawable d = Drawable.c final Resources resources = mContext.getResources(); Drawable d = resources.getDrawable(res.getWeatherIconResId(mContext, today.getConditionCode(), null)); d = ImageUtils.resizeDrawable(mContext, d, 120); //Bitmap b = res.getWeatherIconBitmap(mContext, today.getConditionCode(), null); //mWeatherImageView.setImageResource(res.getWeatherIconResId(mContext, today.getConditionCode(), null)); mWeatherImageView.setImageDrawable(d); }