android,防止toast重复显示的方法

最好是封装在一个方法里面

方法中做判断

	private Toast mtoast;
private void showTextToast(String msg) {
		if (mtoast == null) {
			mtoast = Toast.makeText(getApplicationContext(), msg,
					Toast.LENGTH_SHORT);
		} else {
			mtoast.setText(msg);
		}
		mtoast.show();
	}

这样就只有一个toast对象

猜你喜欢

转载自blog.csdn.net/hx_superman/article/details/51578698