private void showCustomToast(String message,int duration){
  LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.toast_view,null);
  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();
}

private void showCustomToast ( String message , int duration ) { LayoutInflater inflater = ( LayoutInflater ) getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ; View view = inflater . inflate ( R . layout . toast_view , null ) ; 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 ( ) ; }
creates a toast with the specified message .
