Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在我的应用程序的许多屏幕上显示“未找到数据”消息。为此,我创建了一个带有消息和图像的单独布局;现在,我不确定是否应该在所有其他活动的布局中包含该布局或在运行时呈现该布局?什么会更有效率?任何建议都是可观的。
谢谢;
我在所有布局中使用带有文本的文本视图:“未找到数据”,并根据 api 结果设置 VISIBILITY GONE 或 VISIBLE。或者,如果没有找到数据,您可以将视图添加到主布局。像这样;
public showAlert(LinearLayout layout){ TextView textView= new TextView(context); textView.setText("No data found"); layout.addView(textView); }
在一个类中编写这个函数并在你想要的任何地方调用