android - 不能与 ListFragment 中的自定义内容视图一起使用
问题描述
我需要使用方法
setEmptyText();
但是我使用屏幕片段,当我尝试运行我的应用程序时,错误:java.lang.IllegalStateException: Can't be used with a custom content view
退回给我,我读到这是因为我使用的是 Fragment 屏幕造成的。
public class ManejoFragment extends ListFragment ()
遵循返回此错误的方法示例:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setListAdapter(null);
View header = getActivity().getLayoutInflater().inflate(R.layout.device_list_header, null, false);
getListView().addHeaderView(header, null, false);
setEmptyText("Inicializando...");
((TextView) getListView().getEmptyView()).setTextSize(18);
setListAdapter(listAdapter);
}
所有使用该方法的方法都setEmptyText()
返回相同的错误。
解决方案
推荐阅读
- android - 尽管布局为空,但 ScrollView 仍在滚动
- pine-script - Pine Script:当一个接一个地满足两个条件时绘制标签
- windows-installer - 在 U 盘上安装 .msi
- sql - 根据选择的值返回
- typescript - 电子/乏味:需要(“事件”)未定义
- javascript - 我能够使用 GET 请求,但不知道如何发布。如果有人可以快速浏览一下,我已经在这里添加了我的 git 存储库?
- javascript - 在矩形内以一定角度绘制对角线
- javascript - 如何规范化 d3 中的数据并在轴上绘制与其他线范围无关的线
- entity-framework-core - 选择 FROM Subquery 而不从另一个上下文对象开始
- javascript - 有条件避免在文本区域内复制文本不起作用