Toast是Android中的一个常用组件,用法很简单,主要用于提示信息的显示且 不能获得焦点。
不能改变他的事件但是我们可以改变他的样式。
首先我们来看一下平时是怎么使用toast的: Toast.makeText(this,"sehngmsadf",Toast.LENGTH_LONG).show();
那么为什么这样就可以显示一个toast呢?让我们看一下andorid的源码是如何实现的
public static Toast makeText(Context context, CharSequence text, @Duration int duration) {
Toast result = new Toast(context);
LayoutInflater inflate = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflate.inflate(com.android.internal.R.layout.transient_notification, null);
TextView tv = (TextView)v.findViewById(com.android.internal.R.id.message);
tv.setText(text);
result.mNe