Toast setDuration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Toast setDuration method.

This code example shows how to use the following methods:setDuration, setView, show
		TextView message = (TextView) toastLayout.findViewById(R.id.message);
		message.setText("This is my own message");
	} 
 
	public void showMessage(View view) {
		Toast toast = new Toast(this);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.setView(toastLayout);
		toast.show();
	} 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDuration, setGravity, setView, show
	 *           the gravity 
	 */ 
	public static void showCustomToast( int viewResId, int duration, int gravity ) {
		View layout = getLayoutInflater().inflate( viewResId, null );
 
		Toast toast = new Toast( mContext.getApplicationContext() );
 
		toast.setGravity( gravity, 0, 0 );
		toast.setDuration( duration );
		toast.setView( layout );
		toast.show();
	} 
	 
	static PorterDuffColorFilter mWhiteMultiplyFilter = new PorterDuffColorFilter( 0xFFFFFFFF, Mode.MULTIPLY );
 
	/** 
	 * Draw folder icon. 
	 *  
	 * @param folder 
	 *           the folder 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDuration, setGravity, setView, show
This code example shows how to use the following methods:setDuration, setGravity, setView, show
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
                break; 
            } 
        } 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDuration, setGravity, setView, show
    protected void onBrightnessChanged(final int value, final int max) {
        mText.setText(Integer.toString(Math.round(value * 100.0f / max)) + "%");
        mText.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
	int progress = (int) (Math.round(value * 100.0f / max));
	mBrightProg.setProgress(progress);
        mToast.setView(mView);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.TOP, 0, 0);
        mToast.show();
    } 
 
    @Override 
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case MSG_BRIGHTNESS_CHANGED: {
                onBrightnessChanged(msg.arg1, msg.arg2);
                break; 
            } 
        } 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDuration, setView, show
 
public class Util { 
	public static Typeface tf;
 
	public static void raiseAToast(String text, int length, int color, Context context) {
		Toast toast = new Toast(context);
		LinearLayout toastLayout = new LinearLayout(context);
		toastLayout.addView(styleView(new TextView(context), text,
				25, color));
		toast.setView(toastLayout);
		toast.setDuration(length);
		toast.show();
	} 
	 
	public static View styleView(TextView view, String text, int size, int color) {
		view.setText(text);
		view.setTextSize(size);
		view.setTextColor(color);
		view.setTypeface(tf);
		view.setPadding(10, 10, 10, 10);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDuration, setGravity, show
	} 
	 
	public void toast(String text, int length) {
		mText.setText(text);
 
		mToast.setGravity(Gravity.CENTER, 0, 0);
		mToast.setDuration(length);
		mToast.show();
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Toast setDuration Questions & Answers:

setDuration Method Overview
Set how long to show the view for.
See Code Examples for other Android Toast Methods: