ListView不显示

发布于 2024-11-03 00:03:30 字数 1080 浏览 8 评论 0 原文

@Override
public void onConfigurationChanged(Configuration newConfig) {
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.layout_currently);
  if(dHolder.getCurrentItems() == null)
  {
      defineView();
      new LoadCurrent().execute(currentItems);
  }
  else
  {
      try {
          ArrayList<CurrentlyItem> privateCItem = dHolder.getCurrentItems();
          Log.d("ListSize", "There is " + privateCItem.size() + " elements on list");
          int resID = R.layout.current_item;
          Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
          aa = new CurrentAdapter(this, resID, privateCItem, display.getRotation());
          currentListView = (ListView)findViewById(R.id.currentListView);
          currentListView.setAdapter(aa);
          aa.notifyDataSetChanged();
    } catch (Exception e) {
        Log.d(" - ERROR", e.toString());
    }

  }
}

这是一个应该处理屏幕旋转的代码...一切正常,没有任何错误,但列表视图不显示...我收到包含 140 个元素的 ArrayList(由代码中的 Log.d 报告),但由于某种原因列表视图不显示...

感谢您的回答!

@Override
public void onConfigurationChanged(Configuration newConfig) {
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.layout_currently);
  if(dHolder.getCurrentItems() == null)
  {
      defineView();
      new LoadCurrent().execute(currentItems);
  }
  else
  {
      try {
          ArrayList<CurrentlyItem> privateCItem = dHolder.getCurrentItems();
          Log.d("ListSize", "There is " + privateCItem.size() + " elements on list");
          int resID = R.layout.current_item;
          Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
          aa = new CurrentAdapter(this, resID, privateCItem, display.getRotation());
          currentListView = (ListView)findViewById(R.id.currentListView);
          currentListView.setAdapter(aa);
          aa.notifyDataSetChanged();
    } catch (Exception e) {
        Log.d(" - ERROR", e.toString());
    }

  }
}

This is a code which should handle screen rotation... Everything works with no error at all but List View doesn't show... I receive ArrayList with 140 elements (reported by Log.d in code) but for some reason List View doesn't show...

Thanks for your answer!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文