Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:31:54+00:00 2026-05-20T06:31:54+00:00

Hi I am developing one app using the below link Custom ListView With Headers

  • 0

Hi I am developing one app using the below link
Custom ListView With Headers

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;

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 })); 

I am using the image view instead of textview in list_headre.xml.at that time i got the following exception

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)

Now I want to display the image as header instead of TextView.For this please give me some code suggestions.Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:31:55+00:00Added an answer on May 20, 2026 at 6:31 am

    ArrayAdapter only supports TextView views. As per the docs: To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView(int, View, ViewGroup) to return the type of view you want.

    If you just want a single ImageView in the header, I would use my original answer below.

    Original answer: Use the method addHeaderView in ListView and just pass in an ImageView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When developing an app that will listen on a TCP/IP port, how should one
I'm developing a Mac App in Java that logs into any one of our
What are profound advantages that one get when using COM for developing components over
I am developing an ecommerce app that is using the UPS shipping webservice. I
I'm using log4j in an app I'm developing to eventually run inside Tomcat/JBoss, but
one of the programs I'm developing at work is reading the registry to figure
I am developing a Joomla component and one of the views needs to render
i'm developing a simple C# Editor for one of my university courses and I
I'm developing a solution which uses an ActiveX control (a commercial one which we
I am developing iPhone application and In that application I've one TableViewController , and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.