Reputation: 2192
EDIT : this issue now only happens when I try to have a listview with a preview layout that contains databinding (from android databinding)
In android Studio, when I try to add an item preview for a listview, nothing happens (the default preview is still displayed) and in the splitted version (text + preview) I have a black screen for the preview. First I was thinking that my layout was somehow too complex, so I tried with a simple layout file, containing only a LinearLayout and a listview. I checked that the listview has an id (and all the solutions I found on stackoverflow) but nothing works. Here is my layout :
<?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>
And here is the screenshot of the result (the preview is supposed to be on the right). I really need to make this work, and the fact is that the same thing happen whenever I try to use tools:something.
I'm using Android Studio 1.4 Edit : I tried to clone a project that where using tools AND data binding, and the preview works!
Upvotes: 0
Views: 1641
Reputation: 437
Hello I had checked again the UI is rendring atleast for one item. In my it is giving "Rendering Problems onLayout error" while rendering but shows one row item. To make it possible you have to make few changes in xml code:
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView2"
tools:listitem="@layout/item_chat"/>
make sure you are using latest build version tools. I have checked with following:
buildToolsVersion "23.0.0"
classpath 'com.android.tools.build:gradle:1.3.0'
classpath "com.android.databinding:dataBinder:1.0-rc1"
If it still gives try with latest build tools from SDK manager. I have install following plugin in addition:
Android SDK platform-tools version 23.1 rc1 under Tools(Preview channel)
Upvotes: 2