i create a user-defined toast,and i want to get the xml of layout from the layout package,but if i used the code below,there comes a problem:InflateException,i had used many ways to get the layout but fail.the code is below,thanks
public class ImageTextToast
extends Toast {
private Context context;
private String text;
public ImageTextToast(Context context, String text) {
super(context);
this.context = context;
this.text = text;
}
public void initToast() {
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.toast_layout, null);
TextView tv = (TextView) layout.findViewById(R.id.toastText);
tv.setText(text);
setGravity(Gravity.CENTER_VERTICAL, 0, 0);
setDuration(Toast.LENGTH_LONG);
setView(layout);
show();
}
}