I try to use different list item layout depending on the OS version.
So, I created different layouts associated with conditions.
One of them is (in layout/search_result_list_item.xml
)
<?xml version="1.0" encoding="utf-8"?>
<include xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@android:layout/simple_list_item_1">
</include>
it includes the standard "simple_list_item_1".
In my Java code, the layout is associated to the list like this :
adapter = new SimpleCursorAdapter(getActivity(),
R.layout.search_results_list_item,
null,
from,
to,
0);
When a list item is displayed, the following exception is thrown :
android.view.InflateException: Binary XML file line #2: Error inflating class include
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.support.v4.widget.ResourceCursorAdapter.newView(ResourceCursorAdapt
What is wrong ? can't be used as a root item ? despite ADT allows it.
If anyone else is wondering this is the answer:
<?xml version="1.0" encoding="utf-8"?>
<merge>
<include xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@android:layout/simple_list_item_1">
</include>
</merge>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With