Android Toast - 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 Toast class.

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
	 *           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 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: finish, startActivity, setClass, makeText
 
    protected void onPostExecute(String message) {
        dialog.hide();
        dialog.cancel();
 
        Toast.makeText(context,message,Toast.LENGTH_LONG).show();
 
		Intent i = new Intent().setClass(context, TabWidget.class);
		context.startActivity(i);
 
        context.finish();
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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();
	} 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getResources, makeText
 
        final Context context = view.getContext();
        final int viewWidth = view.getWidth();
        final int viewHeight = view.getHeight();
        final int viewCenterX = screenPos[0] + viewWidth / 2;
        final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        final int estimatedToastHeight = (int) (ESTIMATED_TOAST_HEIGHT_DIPS
                * context.getResources().getDisplayMetrics().density);
 
        Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        boolean showBelow = screenPos[1] < estimatedToastHeight;
        if (showBelow) {
            // Show below 
            // Offsets are after decorations (e.g. status bar) are factored in 
            cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
                    viewCenterX - screenWidth / 2,
                    screenPos[1] - displayFrame.top + viewHeight);
        } else { 
            // Show above 
            // Offsets are after decorations (e.g. status bar) are factored in 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Toast Questions & Answers:

See Code Examples for Android Toast Methods: