好的,我有 1 个自定义吐司(xml 布局),效果很好:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout));
ImageView image = (ImageView) layout.findViewById(R.id.logo);
image.setImageResource(R.drawable.logo);
title = (TextView) layout.findViewById(R.id.title);
txt = (TextView) layout.findViewById(R.id.text);
toast = new Toast(appContext);
toast.setGravity(Gravity.FILL_HORIZONTAL|Gravity.BOTTOM, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
但是,当我尝试以相同的方式进行第二次操作时,我收到错误“找不到源”,它并没有真正告诉我什么是错误的。
LayoutInflater infl = getLayoutInflater();
View lay = infl.inflate(R.layout.toast_arrows, (ViewGroup) findViewById(R.id.toast_lay));
toastarrows = new Toast(appContext);
toastarrows.setGravity(Gravity.FILL_HORIZONTAL|Gravity.CENTER, 0, 0);
toastarrows.setDuration(Toast.LENGTH_SHORT);
toastarrows.setView(lay);
toastarrows.show();
我希望这两个祝酒词几乎同时出现在屏幕的不同位置。谁能告诉我这段代码有什么问题?