【发布时间】:2015-11-10 16:28:01
【问题描述】:
编辑:此问题现在仅在我尝试使用包含数据绑定(来自 android 数据绑定)的预览布局的列表视图时发生
在 android Studio 中,当我尝试为列表视图添加项目预览时,没有任何反应(仍显示默认预览),而在拆分版本(文本 + 预览)中,我的预览出现黑屏。 首先我想我的布局有点太复杂了,所以我尝试了一个简单的布局文件,只包含一个 LinearLayout 和一个列表视图。我检查了 listview 是否有一个 id(以及我在 stackoverflow 上找到的所有解决方案),但没有任何效果。这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView2"
android:layout_gravity="center_horizontal"
tools:listitem="@layout/item_chat"/>
</LinearLayout>
这是结果的屏幕截图(预览应该在右侧)。我真的需要完成这项工作,事实上,每当我尝试使用工具时,都会发生同样的事情:某事。
我使用的是 Android Studio 1.4 编辑:我试图克隆一个使用工具和数据绑定的项目,并且预览有效!
【问题讨论】:
-
如果用不同的版本号预览会发生什么?而不是 23,也许尝试 21?或者你有什么?
-
您是否尝试过使用重新加载按钮重新渲染布局?它是否适用于 android studio 的稳定版本?
-
版本号不能解决这个问题,我会试试studio的稳定版(我确定这样的东西在beta中不会消失,也许我错了)
-
还是和android studio 1.3.1一样 :(
-
“我真的需要完成这项工作”只是出于好奇。为什么你需要做这个工作?只要它在设备上正常工作,这个预览只不过是对开发者(就是你)的一个小提示,以及它最终的样子。但只要它在设备上正确显示,为什么需要它来工作?
标签: android android-layout listview android-listview android-studio