Android Toast

        //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() ; 
    } 

 

posted @ 2015-07-01 16:13  赵彦军  阅读(372)  评论(0编辑  收藏  举报