//Toast.LENGTH_SHORT == 0 Toast.makeText( Activity1.this , "点击了" , Toast.LENGTH_SHORT ).show(); Toast.makeText( Activity1.this , "点击了" , 0 ).show(); //Toast.LENGTH_LONG == 1 Toast.makeText( Activity1.this , "点击了" , Toast.LENGTH_LONG ).show(); Toast.makeText( Activity1.this , "点击了" , 1 ).show();
在BaseActivity 里面写一个方法,显示 Toast
private Toast toast ; protected void showToast(String msg, int length) { if (toast == null) { toast = Toast.makeText(this, msg, length); } else { toast.setText(msg); } toast.show() ; }