Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd the imageview as the header of the listview
    primarykey
    data
    text
    <p>Hi I am developing one app using the below link <a href="http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/" rel="nofollow">Custom ListView With Headers</a></p> <p>Now My question is i want to set the image as header for the listview.I am display the list of items using the second type of addsection i.e; </p> <pre><code>adapter.addSection("Security", new SimpleAdapter(this, security, R.layout.list_complex, new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption })); </code></pre> <p>I am using the image view instead of textview in list_headre.xml.at that time i got the following exception </p> <pre><code>02-28 05:43:12.273: ERROR/ArrayAdapter(1212): You must supply a resource ID for a TextView 02-28 05:43:12.273: DEBUG/AndroidRuntime(1212): Shutting down VM 02-28 05:43:12.273: WARN/dalvikvm(1212): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 02-28 05:43:12.283: ERROR/AndroidRuntime(1212): Uncaught handler: thread main exiting due to uncaught exception 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at chronicle.books.shopping.SeparatedListAdapter.getView(SeparatedListAdapter.java:97) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.AbsListView.obtainView(AbsListView.java:1274) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ListView.makeAndAddView(ListView.java:1668) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ListView.fillDown(ListView.java:637) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ListView.fillFromTop(ListView.java:694) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ListView.layoutChildren(ListView.java:1521) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.AbsListView.onLayout(AbsListView.java:1113) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.onLayout(LinearLayout.java:918) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ScrollView.onLayout(ScrollView.java:1108) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.LinearLayout.onLayout(LinearLayout.java:918) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:900) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.View.layout(View.java:6830) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.ViewRoot.performTraversals(ViewRoot.java:996) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.os.Handler.dispatchMessage(Handler.java:99) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.os.Looper.loop(Looper.java:123) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at java.lang.reflect.Method.invokeNative(Native Method) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at java.lang.reflect.Method.invoke(Method.java:521) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at dalvik.system.NativeStart.main(Native Method) 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): Caused by: java.lang.ClassCastException: android.widget.ImageView 02-28 05:43:12.322: ERROR/AndroidRuntime(1212): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340) </code></pre> <p>Now I want to display the image as header instead of TextView.For this please give me some code suggestions.Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload