These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ImageSwitcher class.
_imageSwitcher.setInAnimation(animLIn); _imageSwitcher.setOutAnimation(animLOut); } else { _imageSwitcher.setInAnimation(animFIn); _imageSwitcher.setOutAnimation(animFOut); } if (_imageSwitcher.getCurrentView() == _artView1) { _artView2.setImageResource(newRESID); _imageSwitcher.showNext(); } else { _artView1.setImageResource(newRESID); _imageSwitcher.showPrevious(); } } }
} public void goNext() { Animation in = AnimationUtils.loadAnimation(context, android.R.anim.fade_in); imageSwitcher.startAnimation(in); } public void goPrevious() { Animation out = AnimationUtils.loadAnimation(context, android.R.anim.fade_in); imageSwitcher.startAnimation(out); } public ImageView imageView() { ImageView i = new ImageView(context); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
g.setAdapter(new ImageAdapter(this)); g.setOnItemSelectedListener(this); } public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { mSwitcher.setImageResource(mImageIds[position]); } public void onNothingSelected(AdapterView<?> parent) { } public View makeView() { ImageView i = new ImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return i; }
super.onCreate(savedInstanceState); // 创建一个线性布局LinearLayout LinearLayout main_view = new LinearLayout(this); // 创建ImageSwitcher对象 m_Switcher = new ImageSwitcher(this); // 在线性布局中添加ImageSwitcher视图 main_view.addView(m_Switcher); // 设置ImageSwitcher对象的ID m_Switcher.setId(SWITCHER_ID); // 设置ImageSwitcher对象的数据源 m_Switcher.setFactory(this); // added by Tom Xue, same function as "next Button" // so that its SWITCHER_ID is useful m_Switcher.setOnClickListener(this); // m_Switcher is the 1st View (the image, see above addView) on the // screen, below function makes it on screen at the very beginning, by // Tom Xue m_Switcher.setImageResource(imagelist[index]);
} return row; } private View createImageSwitch(int x, int y, Drawable img){ ImageSwitcher imageSwitcher=new ImageSwitcher(getApplicationContext()); imageSwitcher.setId(100*x+y); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); imageSwitcher.setImageDrawable(img); // imageSwitcher.set return imageSwitcher; } }
final int stub_id=R.drawable.stub; public void DisplayImage(final List<String> urls, final ImageSwitcher imageSwitcher) { imageSwitcher.setFactory(this); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_out)); String url = urls.get(0); imageViews.put(imageSwitcher, url); final Bitmap bitmap=memoryCache.get(url); if(bitmap!=null) { handler.post(new Runnable() { @Override public void run() { imageSwitcher.setImageDrawable(new BitmapDrawable(bitmap)); } });
super.onCreate(savedInstanceState); //����һ�����Բ���LinearLayout LinearLayout main_view = new LinearLayout(this); //����ImageSwitcher���� m_Switcher = new ImageSwitcher(this); //�����Բ���������ImageSwitcher��ͼ main_view.addView(m_Switcher); //����ImageSwitcher������ID m_Switcher.setId(SWITCHER_ID); //����ImageSwitcher����������Դ m_Switcher.setFactory(this); m_Switcher.setImageResource(imagelist[index]); //������ʾ���洴�������Բ��� setContentView(main_view); //��������һ�š���ť Button next = new Button(this); next.setId(BUTTON_DWON_ID);
super.onCreate(savedInstanceState); //´´½¨Ò»¸öÏßÐÔ²¼¾ÖLinearLayout LinearLayout main_view = new LinearLayout(this); //´´½¨ImageSwitcher¶ÔÏó m_Switcher = new ImageSwitcher(this); //ÔÚÏßÐÔ²¼¾ÖÖÐÌí¼ÓImageSwitcherÊÓͼ main_view.addView(m_Switcher); //ÉèÖÃImageSwitcher¶ÔÏóµÄID m_Switcher.setId(SWITCHER_ID); //ÉèÖÃImageSwitcher¶ÔÏóµÄÊý¾ÝÔ´ m_Switcher.setFactory(this); m_Switcher.setImageResource(imagelist[index]); //ÉèÖÃÏÔʾÉÏÃæ´´½¨µÄÏßÐÔ²¼¾Ö setContentView(main_view); //´´½¨¡°ÏÂÒ»ÕÅ¡±°´Å¥ Button next = new Button(this); next.setId(BUTTON_DWON_ID);
@Override protected void onPostExecute(Bitmap result) { // we check if the user is still looking at the same photo // if not, we don't refresh the main view if (result != null && originalPosition == gallery.getSelectedItemPosition()) { imageSwitcher.setImageDrawable(new BitmapDrawable((Bitmap) result)); } } }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position , long id) { //��ʾ��ǰ��ѡ�е�ͼƬ switcher.setImageResource(imageIds[position % imageIds.length]); } @Override public void onNothingSelected(AdapterView<?> parent){} }); //�����б�������ļ����� grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent , View view, int position, long id) { //��ʾ��������ͼƬ��ͼƬ switcher.setImageResource(imageIds[position % imageIds.length]); }