9.24

直接调用Toast类的makeText()方法创建:

void midToast(String str, int showTime)
{
    Toast toast = Toast.makeText(global_context, str, showTime);            
    toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL , 0, 0);  //设置显示位置
    TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
    v.setTextColor(Color.YELLOW);     //设置字体颜色
    toast.show();   
}
posted @ 2021-09-24 19:27  平安喜乐v  阅读(29)  评论(0编辑  收藏  举报