Android ViewSwitcher - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ViewSwitcher class.

This code example shows how to use the following methods:getContext, setText, setInAnimation, setOutAnimation, setFactory
 
    /** 
     * Initializes the score TextSwitcher for the specified {@code textSwitcher}. 
     */ 
    private void initializeTextSwitcher(final TextSwitcher textSwitcher) {
        textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
            @Override 
            public View makeView() {
                TextView textView = new TextView(textSwitcher.getContext());
                textView.setTextSize(26);
                return textView;
            } 
        }); 
 
        textSwitcher.setInAnimation(AnimationUtils.loadAnimation(textSwitcher.getContext(), android.R.anim.fade_in));
        textSwitcher.setOutAnimation(AnimationUtils.loadAnimation(textSwitcher.getContext(), android.R.anim.fade_out));
        textSwitcher.setText("1");
    } 
 
} 

6
CodeRank
This code example shows how to use the following methods:setId, setOnClickListener, setImageResource, setFactory
		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]);
 

6
CodeRank
This code example shows how to use the following methods:getTag, setPadding, setTag, addView, getChildAt
	public View getView(int position, View convertView, ViewGroup parent) {
    	final ViewSwitcher lViewSwitcher;
		String url = mUrls[position];
		ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
        	lViewSwitcher = new ViewSwitcher(mContext);
			lViewSwitcher.setPadding(0, 0, 0, 0);
			ProgressBar lProgress = new ProgressBar(mContext);
			lProgress.setLayoutParams(new ViewSwitcher.LayoutParams(40, 40));
			lViewSwitcher.addView(lProgress);
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(5, 5, 5, 5);
            lViewSwitcher.addView(imageView);
             
            // attach the onclick listener 
			//lViewSwitcher.setOnClickListener(new ClickHandler()); 
        } else { 
        	lViewSwitcher = (ViewSwitcher) convertView;

6
CodeRank
This code example shows how to use the following methods:setBackgroundResource, setInAnimation, setOutAnimation, setFactory
			// imageView.setMaxHeight(400); 
			// imageView.setAdjustViewBounds(true); 
			// imageView.setImageResource(imageList[position]); 
			// return imageView; 
 
			ViewSwitcher sSwitcher = new ViewSwitcher(context);
			sSwitcher.setFactory(ssf);
			// mSwitcher.setImageResource(imageList[position]); 
			sSwitcher.setBackgroundResource(imageList[position]);
			sSwitcher.setInAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_in));
			sSwitcher.setOutAnimation(AnimationUtils.loadAnimation(context, android.R.anim.fade_out));
			return sSwitcher;
		} 
	} 
 
	@Override 
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{ 
		if (requestCode == 0)
		{ 
6
CodeRank
This code example shows how to use the following methods:setInAnimation, setOutAnimation, setFactory
     
    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)); 
            	} 
            }); 

6
CodeRank
This code example shows how to use the following methods:setId, setImageResource, setFactory
        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);
6
CodeRank
This code example shows how to use the following methods:setId, setImageResource, setFactory
		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);
6
CodeRank
This code example shows how to use the following methods:getDisplayedChild, showPrevious
 
            @Override 
            public void onClick(View v) {
                ViewSwitcher switcher = (ViewSwitcher) v;
 
                if (switcher.getDisplayedChild() == 0) {
                    switcher.showNext();
                } else { 
                    switcher.showPrevious();
                } 
            } 
        }); 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:setAnimateFirstView, setDisplayedChild
This code example shows how to use the following methods:setInAnimation, setOutAnimation, setFactory
	} 
	 
	protected TextSwitcher createTextSwitcher(Activity activity, int textswitcherId) {
		TextSwitcher textSwitcher;
		textSwitcher = (TextSwitcher) findViewById(textswitcherId);
		textSwitcher.setFactory((ViewFactory) activity);
		Animation in = AnimationUtils.loadAnimation(this,android.R.anim.fade_in);
		Animation out = AnimationUtils.loadAnimation(this,android.R.anim.fade_out);
		textSwitcher.setInAnimation(in);
		textSwitcher.setOutAnimation(out);
		return textSwitcher;
	} 
	 
	public void startBrowserWithUrl(String url) {
		Intent browserIntent = IntentManager.getInstance().createViewIntent(url);
		startActivity(browserIntent);
	} 
	 
	public boolean isNetworkAvailable() { 
		  boolean HaveConnectedWifi = false;		   
5
CodeRank

Related Android ViewSwitcher Questions & Answers:

See Code Examples for Android ViewSwitcher Methods: