you can do it this way. create a custom toast with a textview in it (R.id.text).
use a class which extends from CountDownTimer class to control the amount of time you want to show the toast for. for
eg: MyCount counter = new MyCount(5000,1000);
will show the toast for 5 seconds. lower the values to get your desired results.
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toastxml,
(ViewGroup) findViewById(R.id.toast_layout_root));
toast = new Toast(this);
toast.setView(layout);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello! This is a custom toast!");
MyCount counter = new MyCount(5000,1000);
counter.start();
class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
toast.cancel();
}
@Override
public void onTick(long millisUntilFinished) {
toast.show();
}
}