private void initSwitchers() { temperatureSwitcher = (TextSwitcher) findViewById(R.id.ts_temperature); temperatureSwitcher.setFactory(new TextViewFactory(R.style.TemperatureTextView, true)); temperatureSwitcher.setCurrentText(temperatures[0]); placeSwitcher = (TextSwitcher) findViewById(R.id.ts_place); placeSwitcher.setFactory(new TextViewFactory(R.style.PlaceTextView, false)); placeSwitcher.setCurrentText(places[0]); clockSwitcher = (TextSwitcher) findViewById(R.id.ts_clock); clockSwitcher.setFactory(new TextViewFactory(R.style.ClockTextView, false)); clockSwitcher.setCurrentText(times[0]); descriptionsSwitcher = (TextSwitcher) findViewById(R.id.ts_description); descriptionsSwitcher.setInAnimation(this, android.R.anim.fade_in); descriptionsSwitcher.setOutAnimation(this, android.R.anim.fade_out); descriptionsSwitcher.setFactory(new TextViewFactory(R.style.DescriptionTextView, false)); descriptionsSwitcher.setCurrentText(getString(descriptions[0])); mapSwitcher = (ImageSwitcher) findViewById(R.id.ts_map); mapSwitcher.setInAnimation(this, R.anim.fade_in); mapSwitcher.setOutAnimation(this, R.anim.fade_out); mapSwitcher.setFactory(new ImageViewFactory()); mapSwitcher.setImageResource(maps[0]); mapLoadListener = new DecodeBitmapTask.Listener() { @Override public void onPostExecuted(Bitmap bitmap) { ((ImageView)mapSwitcher.getNextView()).setImageBitmap(bitmap); mapSwitcher.showNext(); } }; }
@Override public void onClick(View arg0) { if (idx == imagens.length) { idx = 0; // fim do array } imageSwitcher.setImageResource(imagens[idx++]); } });
/** * load the resource images * * @param pictureIndex index */ private void loadFileImage(int pictureIndex) { if (list != null && list.size() != 0) { switcherImage.setImageResource((Integer) list.get(pictureIndex)); } }