Java Code Examples for android.widget.Toast.setView()

The following are Jave code examples for showing how to use setView() of the android.widget.Toast class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.

+ Save this method
Example 1
Project: VoiceRecord-master View Source Vote up 6 votes
private void showWarnToast(String toastText) {
    Toast toast = new Toast(mContext);
    View warnView = LayoutInflater.from(mContext).inflate(
            R.layout.toast_warn, null);
    toast.setView(warnView);
    toast.setGravity(Gravity.CENTER, 0, 0);// ???????
    toast.show();
}
 
Example 2
Project: Todayinformation-master View Source Vote up 6 votes
/**
 * ??????UI
 */
public static void showCollectionUI(Context context) {
	View view = LayoutInflater.from(context).inflate(
			R.layout.custom_collection, null);
	Toast toast = new Toast(context);
	toast.setView(view);
	toast.setGravity(Gravity.CENTER, 0, 0);
	toast.show();
}
 
Example 3
Project: sinaBlog-master View Source Vote up 6 votes
public static Toast makeText(Context context, CharSequence text,
		int duration) {
	Toast result = new Toast(context);

	LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	View layout = inflater.inflate(R.layout.custom_toast, null);

	TextView textView = (TextView) layout.findViewById(R.id.toast);
	DisplayMetrics dm2 = context.getResources().getDisplayMetrics();
	textView.setWidth(dm2.widthPixels);
	textView.setText(text);

	result.setView(layout);
	result.setGravity(Gravity.CENTER, 0, 0);
	result.setDuration(duration);

	return result;
}
 
Example 4
Project: dubsar_android-master View Source Vote up 6 votes
public Group(GroupType type, String name, String help) {
	mType = type;
	mName = name;
	
	if (getContext() != null) {
		LayoutInflater inflater = 
				(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View toastView = inflater.inflate(R.layout.toast, null);
		TextView toastText = (TextView)toastView.findViewById(R.id.toast);

		mHelp = new Toast(getContext());
		toastText.setText(help);
		
		mHelp.setView(toastView);
	}
}
 
Example 5
Project: DemoProject-master View Source Vote up 6 votes
private void showOverlay() {
    // Generate a toast view with a special layout that will position itself right
    // on top of this view's interesting widgets.  Sneaky huh?
    SecureViewOverlay overlay = (SecureViewOverlay)
            getLayoutInflater().inflate(R.layout.secure_view_overlay, null);
    overlay.setActivityToSpoof(this);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.FILL, 0, 0);
    toast.setView(overlay);
    toast.show();
}
 
Example 6
Project: okjsp-android-master View Source Vote up 6 votes
public static Toast makeText(Context context, String msg, int icon_id, int duration) {
    switch (icon_id) {
        case TYPE_INFO:
        	// TODO: need to change icon for indicating informations
            icon_id = R.drawable.ic_launcher;
            break;
        case TYPE_WARNING:
        	// TODO: need to change icon for indicating warnings
            icon_id = R.drawable.ic_launcher;
            break;
        default:
            icon_id = R.drawable.ic_launcher;
            break;
    }

    View view = getToastView(context, msg, icon_id);
    
    Toast toast = new Toast(context);              
    toast.setDuration(duration);
    toast.setView(view);
    return toast;
}
 
Example 7
Project: jdroid-master View Source Vote up 6 votes
/**
 * Show the {@link Toast} on the current Thread.
 * 
 * @param imageId The id of the image to display
 * @param message The text to show. Can be formatted text.
 * @param duration How long to display the message. Either {@link Toast#LENGTH_SHORT} {@link Toast#LENGTH_LONG}
 * @param gravity The location at which the notification should appear on the screen.
 * @param xOffset The X offset in pixels to apply to the gravity's location.
 * @param yOffset The Y offset in pixels to apply to the gravity's location.
 */
public static void showCustomToast(Integer imageId, String message, int duration, Integer gravity, Integer xOffset,
		Integer yOffset) {
	AbstractApplication androidApplication = AbstractApplication.get();
	if (!androidApplication.isInBackground()) {
		
		LayoutInflater inflater = LayoutInflater.from(androidApplication);
		View view = inflater.inflate(R.layout.toast_custom, null);
		
		if (imageId != null) {
			ImageView imageView = (ImageView)view.findViewById(R.id.toastImage);
			imageView.setImageResource(imageId);
			imageView.setVisibility(View.VISIBLE);
		}
		
		TextView textView = (TextView)view.findViewById(R.id.toastMessage);
		textView.setText(message);
		
		cancelCurrentToast();
		
		Toast toast = new Toast(androidApplication);
		if ((gravity != null) && (xOffset != null) && (yOffset != null)) {
			toast.setGravity(gravity, xOffset, yOffset);
		}
		toast.setDuration(duration);
		toast.setView(view);
		toast.show();
		
		currentToast = new WeakReference<>(toast);
	}
}
 
Example 8
Project: andevcon-2014-jl-master View Source Vote up 6 votes
private void showOverlay() {
    // Generate a toast view with a special layout that will position itself right
    // on top of this view's interesting widgets.  Sneaky huh?
    SecureViewOverlay overlay = (SecureViewOverlay)
            getLayoutInflater().inflate(R.layout.secure_view_overlay, null);
    overlay.setActivityToSpoof(this);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.FILL, 0, 0);
    toast.setView(overlay);
    toast.show();
}
 
Example 9
Project: gcmobile-master View Source Vote up 6 votes
/**
 * Creates a toast with the specified message.
 * 
 * @param message
 */
private void showCustomToast(String message, int duration) {
    LayoutInflater inflater =
        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = inflater.inflate(R.layout.toast_view, null);

    // set the text in the view
    TextView tv = (TextView) view.findViewById(R.id.message);
    tv.setText(message);

    Toast t = new Toast(this);
    t.setView(view);
    t.setDuration(duration);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();
}
 
Example 10
Project: Tofu-Notes-master View Source Vote up 6 votes
private static void toast(Context ctx, String text, int duration) {
	Toast toastView = new Toast(ctx);
       toastView.setView(Umlaut.getTofuToastView(ctx, text));
       toastView.setDuration(duration);
       toastView.setGravity(Gravity.BOTTOM | Gravity.LEFT, 0,0);
       toasts.add(toastView);
       toastView.show();
}
 
Example 11
Project: motivator-master View Source Vote up 6 votes
/**
 * Displaying toast after checking events
 */
private void eventsChecked() {
	View toastLayout = (View) getLayoutInflater().inflate(R.layout.element_mood_toast, (ViewGroup) findViewById(R.id.mood_toast_layout));
	TextView toastText = (TextView) toastLayout.findViewById(R.id.mood_toast_text);
	toastText.setText(getString(R.string.plan_checked));
	toastText.setTextColor(Color.WHITE);
	
	
	Toast planChecked = new Toast(getApplicationContext());
	planChecked.setDuration(Toast.LENGTH_SHORT);
	planChecked.setView(toastLayout);
	planChecked.show();
	
	finish();
}
 
Example 12
Project: YANA-master View Source Vote up 6 votes
@Override
public void onCreate(){
	super.onCreate();
	LayoutInflater layoutInflater = (LayoutInflater)
			   getSystemService(LAYOUT_INFLATER_SERVICE);
	View layout = layoutInflater.inflate(R.layout.toast_layout, null);
	
	toast = new Toast(getApplicationContext());
	toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 80);
	textView = (TextView) layout.findViewById(R.id.text);
	toast.setDuration(Toast.LENGTH_LONG);
	toast.setView(layout);
	
	Yana.eventstate=true;

	pick_JSON();}
 
Example 13
Project: O2OMobile_Android-master View Source Vote up 6 votes
public ToastView(Context context, String text) {
	LayoutInflater inflater = LayoutInflater.from(context);
	View view = inflater.inflate(R.layout.toast_view, null);
	TextView t = (TextView) view.findViewById(R.id.toast_text);
	t.setText(text);
	if(toast != null) {
		toast.cancel();
	}
	toast = new Toast(context);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(view);
}
 
Example 14
Project: apidemo-master View Source Vote up 6 votes
/**
 * The toast pops up a quick message to the user showing what could be
 * the text of an incoming message.  It uses a custom view to do so.
 */
protected void showToast() {
    // create the view
    View view = inflateView(R.layout.incoming_message_panel);

    // set the text in the view
    TextView tv = (TextView)view.findViewById(R.id.message);
    tv.setText("khtx. meet u for dinner. cul8r");

    // show the toast
    Toast toast = new Toast(this);
    toast.setView(view);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.show();
}
 
Example 15
Project: AdvancedVideoView-master View Source Vote up 6 votes
public void show(float progress) {
	if (t == null) {
		t = new Toast(context);
		View layout = LayoutInflater.from(context).inflate(R.layout.vv, null);
		tv = (VolumnView) layout.findViewById(R.id.volumnView);
		t.setView(layout);
		t.setGravity(Gravity.BOTTOM, 0, 100);
		t.setDuration(Toast.LENGTH_SHORT);
	}
	tv.setProgress(progress);
	t.show();
}