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

  • Home
  • SEARCH
  • 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 6172419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:23:22+00:00 2026-05-23T23:23:22+00:00

I have a Listview in my xml. The structure of it like that: <ListView

  • 0

I have a Listview in my xml. The structure of it like that:

<ListView 
    android:id="@+id/SeriesCastListItemView"
    android:paddingTop="10dip"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:divider="#FFFFFF"
    android:dividerHeight="1px"/>

Now I want to set a height for the Listview by java code. i am tried with following code.

ListView castListItemView = (ListView) findViewById(R.id.SeriesCastListItemView);
castListItemView.setAdapter(new CastAdapter(this, castDescriptionArr));
castListItemView.setLayoutParams(new ListView.LayoutParams(LayoutParams.FILL_PARENT, 500));

But it giving java.lang.ClassCastException: android.widget.AbsListView$LayoutParams. What is the problem in my code?

  • 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-23T23:23:23+00:00Added an answer on May 23, 2026 at 11:23 pm

    You should be using the LayoutParams of the parent view that contains your ListView. In my case, I placed the ListView in a Frame Layout, and used this code. If you placed the ListView in a LinearLayout you would use LinearLayout.LayoutParams.

    ListView castListItemView = (ListView) findViewById(R.id.SeriesCastListItemView);
    castListItemView.setAdapter(new CastAdapter(this, castDescriptionArr));
    castListItemView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, 500));
    

    I assume it was a typo in your question, but make sure that the “c” in castListItemView is lowercase on your third line.

    MrJre brings up a good point though. Because many different views have their own LayoutParams, it is best to include the view whose parameters you wish to use (as in FrameLayout.LayoutParams) instead of making Eclipse guess based on which LayoutParams class you previously imported.

    You can see this previous question for more information.

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

Sidebar

Related Questions

I have a ListView in main.xml where android:entries=@array/list1 and I'd like to update that
I have a ListView ( my_list.xml ): <ListView android:id=@+id/my_list android:layout_width=wrap_content android:layout_height=wrap_content android:choiceMode=singleChoice /> The
I have listView , each row of which is looking like that: <?xml version=1.0
I have listview item like below <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=60dp android:orientation=horizontal android:descendantFocusability=blocksDescendants > <TextView
I have a ListView that is populated using an XML file. However, I want
I have a ListView that has a custom ArrayAdapter with a custom XML row.
enter code here I have a ListView that have a different Layout XML for
I have a rather simple ListView row: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content
I have a listview that loads dynamic controls from xml/xslt <asp:ListView ID=DynamicFields runat=server DataSourceID=CustomFields
I have a ListView that inflate for each row a xml that contain a

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.