Android TextSwitcher - 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 TextSwitcher 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:setText
        mCounter++;
        updateCounter(); 
    } 
 
    private void updateCounter() { 
        mSwitcher.setText(String.valueOf(mCounter));
    } 
 
    public View makeView() {
        TextView t = new TextView(this);
        t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
        t.setTextSize(36);
        return t;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setText, getInAnimation, getOutAnimation, setInAnimation, setOutAnimation
This code example shows how to use the following methods:setInAnimation, setOutAnimation
 
    mSwitchHour.setInAnimation( in_anim );
    mSwitchHour.setOutAnimation( out_anim );
    mSwitchMin.setInAnimation( in_anim );
    mSwitchMin.setOutAnimation( out_anim );
    mSwitchSec.setInAnimation( in_anim );
    mSwitchSec.setOutAnimation( out_anim );
  } 
  public void updateClock() 
  { 
    boolean is24 = Alarms.get24HourMode(this);
    mCal.setTime(new Date());
 
 
    String s;
    s = DateFormat.format(is24 ? "k:" : "h:",mCal).toString();
    if (!s.equals(mHour)) {
        mSwitchHour.setText(mHour = s);
    } 
    s = DateFormat.format(mOrient == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ? "mm:" : "mm", mCal).toString();
5
CodeRank
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
This code example shows how to use the following methods:setText
 
	@Override 
	public void run() { 
		// TODO Auto-generated method stub 
		try { 
			switcher.setText(comments[commentIndex++]);
			if (commentIndex >= comments.length) {
				commentIndex = 0;
			} 
		} finally { 
			switcherCommentsHandler.postDelayed(this, 5 * 1000);
		} 
 
	} 
 
	@Override 
	public void onItemSelected(AdapterView<?> parent, View view, int position,
			long id) {
		// TODO Auto-generated method stub 
 
3
CodeRank
This code example shows how to use the following methods:setText
    if (!s.equals(mHour)) {
        mSwitchHour.setText(mHour = s);
    } 
    s = DateFormat.format(mOrient == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ? "mm:" : "mm", mCal).toString();
    if (!s.equals(mMin)) {
        mSwitchMin.setText(mMin = s);
    } 
    s = DateFormat.format("ss",mCal).toString();
    if (!s.equals(mSec)) {
        mSwitchSec.setText(mSec = s);
    } 
  } 
 
  public View makeView() {
    return mInflater.inflate(R.layout.bedclock_text, null);
  } 
 
  public void onClick(View v) { finish(); }
 
  @Override 
3
CodeRank
This code example shows how to use the following methods:setText
		String combined = applicationlabel;
		if (!TextUtils.isEmpty(versionname)) {
			combined += " " + versionname;
		} 
		 
        mProgramNameAndVersionText.setText(combined);
	} 
 
	/** 
	 * Get application label. 
	 *  
	 * @param intent The intent from which to fetch the information. 
	 */ 
	protected String getApplicationLabel(final String packagename, final Intent intent) {
		String applicationlabel = null;
		if (intent.hasExtra(AboutIntents.EXTRA_APPLICATION_LABEL)
				&& intent.getStringExtra(AboutIntents.EXTRA_APPLICATION_LABEL) 
					!= null) { 
			applicationlabel = intent.getStringExtra(AboutIntents.EXTRA_APPLICATION_LABEL);
		} else { 
3
CodeRank
This code example shows how to use the following methods:setText
		switchCommentHandler.removeCallbacks(this);
	} 
 
	public void run() { 
		try { 
			switcher.setText(comments[commentIndex++]);
			if (commentIndex >= comments.length) {
				commentIndex = 0;
			} 
		} finally { 
			switchCommentHandler.postDelayed(this, 5 * 1000l);
		} 
	} 
 
	@Override 
	public void onItemSelected(AdapterView<?> parent, View view, int position,
			long id) {
		photo.setImageDrawable(Utils.LoadImageFromWebOperations((String) photos
				.getAdapter().getItem(position)));
	} 
4
CodeRank
This code example shows how to use the following methods:setText
    } 
 
    private void addAndCheckForUnlock(EntryCode event) {
        String eventString = getEventString(event);
         
        textSwitcher.setText(eventString);
         
        queue.add(event);
        guestQueue.add(event);
        if (isCorrectCode()) { 
            unlock(); 
        } else if (isGuestCode()) { 
            guestUnlocked();  
        } 
    } 
 
    private String getEventString(EntryCode event) {
         
        switch(event) {
            case FLING_LEFT:
4
CodeRank

Related Android TextSwitcher Questions & Answers:

See Code Examples for Android TextSwitcher Methods: