【发布时间】:2015-01-04 16:08:12
【问题描述】:
我有简单的自定义吐司,它在类范围活动中工作正常,但在 片段 中我有一个问题。
findviewbyid 方法在片段中不起作用!!
我该如何解决?
LayoutInflater inflater = getLayoutInflater();
View layouttoast = inflater.inflate(R.layout.customtoast, (ViewGroup)findViewById(R.id.toastcustom));
((TextView) layouttoast.findViewById(R.id.texttoast)).setText(message);
layouttoast.findViewById(R.id.imagetoast)).setBackgroundResource(R.drawable.icon);
Toast mytoast = new Toast(getBaseContext());
mytoast.setView(layouttoast);
mytoast.setDuration(Toast.LENGTH_LONG);
mytoast.show();
【问题讨论】:
标签: android android-fragments android-toast