Hi,
    I know it is possible to place ListView into Fragment, aka.
ListFragment.
But is it possible to place Fragment into ListView?

What I'm trying to achieve is I created a reusable Fragment A that
works fine anywhere outside ListView, but when I try to inflate
Fragment A into a ListView item, I get

InflateException: Binary XML file line #18: Error inflating class
fragment

My Sample code follows:
ReadScreenExpandItem.java (This file is one of the listview item)
In my constructor, I call
((LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
                R.layout.read_screen_expand_item, this);

read_screen_expand_item.xml (This file is ReadScreenExpandItem.java's
layout)
<merge xmlns:android="http://schemas.android.com/apk/res/android";>
.. other views..
      <fragment
class="com.xxx.android.mail.fragment.ReadScreenRecipientFragment"
                      android:id="@+id/recipientToArea"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                   />
.. other views..
</merge>

Right after calling LayoutInflator::inflate, I get the following error
messages

E/AndroidRuntime( 8143): FATAL EXCEPTION: main
E/AndroidRuntime( 8143): android.view.InflateException: Binary XML
file line #18: Error inflating class fragment
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:459)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime( 8143):        at
com.xxx.android.mail.widget.ReadScreenExpandItem.init(ReadScreenExpandItem.java:
218)
E/AndroidRuntime( 8143):        at
com.xxx.android.mail.widget.ReadScreenExpandItem.<init>(ReadScreenExpandItem.java:
127)
E/AndroidRuntime( 8143):        at
com.xxx.android.mail.activity.ReadThreadActivity
$MailThreadAdapter.getView(ReadThreadActivity.java:1691)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxHeaderViewListAdapter.getView(XxxHeaderViewListAdapter.java:
272)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxAbsListView.obtainView(XxxAbsListView.java:2265)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxListView.makeAndAddView(XxxListView.java:2071)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxListView.fillSpecific(XxxListView.java:1607)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxListView.layoutChildren(XxxListView.java:1914)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxAbsListView.onLayout(XxxAbsListView.java:2083)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
com.xxx.widget.XxxOverlapLayout.onLayout(XxxOverlapLayout.java:399)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
android.widget.FrameLayout.onLayout(FrameLayout.java:431)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
android.widget.FrameLayout.onLayout(FrameLayout.java:431)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
android.widget.FrameLayout.onLayout(FrameLayout.java:431)
E/AndroidRuntime( 8143):        at android.view.View.layout(View.java:11359)
E/AndroidRuntime( 8143):        at
android.view.ViewGroup.layout(ViewGroup.java:4531)
E/AndroidRuntime( 8143):        at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1665)
E/AndroidRuntime( 8143):        at
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2695)
E/AndroidRuntime( 8143):        at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 8143):        at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime( 8143):        at
android.app.ActivityThread.main(ActivityThread.java:4977)
E/AndroidRuntime( 8143):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 8143):        at
java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 8143):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 8143):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 8143):        at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 8143): Caused by: java.lang.ClassNotFoundException:
android.view.fragment
E/AndroidRuntime( 8143):        at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 8143):        at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 8143):        at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.createView(LayoutInflater.java:552)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
E/AndroidRuntime( 8143):        at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:
66)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
E/AndroidRuntime( 8143):        at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
E/AndroidRuntime( 8143):        ... 40 more

Please kindly help whether I have done anything incorrectly.

thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to