I want to create a toast message with background color is white and message color is black. My toast message is:
Toast.makeText(Logpage.this, \"Please Give
Create a layout file toast.xml as to how your toast should look as below:
To show the toast in the java file put the below code:
public void showCustomAlert()
{
Context context = getApplicationContext();
// Create layout inflator object to inflate toast.xml file
LayoutInflater inflater = getLayoutInflater();
// Call toast.xml file for toast layout
View toastView = inflater.inflate(R.layout.toast, null);
Toast toast = new Toast(context);
toastView.setView(toast);
// Set layout to toast
toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,
0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}