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 3680926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:38:03+00:00 2026-05-19T03:38:03+00:00

I have a LinearLayout which I wanna inflate into my SectionedAdapter as a Header

  • 0

I have a LinearLayout which I wanna inflate into my SectionedAdapter as a Header. LinearLayout have one ImageView and one TextView. I tried this but it’s not working…

SectionedAdapter adapter = new SectionedAdapter() {
 protected View getHeaderView(String caption, int index, View convertView, ViewGroup parent) {
 TextView result=(TextView)convertView;

if (convertView == null) {
result = (TextView) getLayoutInflater().inflate(R.layout.my_main_layout, null).findViewById(R.id.label);
}
result.setText(caption);

return(result);
 }
};

I get

01-09 21:23:02.336: ERROR/AndroidRuntime(308): FATAL EXCEPTION: main
01-09 21:23:02.336: ERROR/AndroidRuntime(308): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.ListView.setupChild(ListView.java:1761)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.ListView.makeAndAddView(ListView.java:1730)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.ListView.fillDown(ListView.java:652)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.ListView.fillFromTop(ListView.java:709)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.ListView.layoutChildren(ListView.java:1580)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.AbsListView.onLayout(AbsListView.java:1147)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.View.layout(View.java:7035)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.os.Looper.loop(Looper.java:123)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at java.lang.reflect.Method.invokeNative(Native Method)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at java.lang.reflect.Method.invoke(Method.java:521)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-09 21:23:02.336: ERROR/AndroidRuntime(308):     at dalvik.system.NativeStart.main(Native Method)

Ofcourse, casting (TextView) is a problem..?

  • 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-19T03:38:03+00:00Added an answer on May 19, 2026 at 3:38 am

    THe error means that you are trying to cast something a cast is something that looks like this:

    (SomeClass) SomeFunctionThatReturnsAnObject();
    

    If the functions returns an object that is not from the correct class, you will get this error. I don’t know what line returned the error, and what the linenumbers in your code are, but you have a “findViewById” call. That will return a View. If that View is a TextView, you can cast it to (TextView), but if it’s not, you can’t.

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

Sidebar

Related Questions

I have a LinearLayout, which only contains one button. I want this button to
I have a ViewGroup (LinearLayout) which contains a couple of TextViews and one ImageView.
I have a linear layout which consists of imageview and textview , one below
I can't create layout in which I will have <LinearLayout> <TextView/> <ExpandableListView/> <Button/> </LinearLayout>
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a LinearLayout which has a background image (a 9 patched png file).
I have a horizontal LinearLayout, inside which I have 2 TextViews. Let's say that
Basically, I have a custom ListView in which each item looks like: <LinearLayout> <Table>
I have an AbsoluteLayout which has an OnTouchListener . Inside this layout there is
I have an extended ImageView that I'm reusing 7 times horizontally (within a LinearLayout)

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.