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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:31:39+00:00 2026-05-25T00:31:39+00:00

Hi I am fetching data for List View from web and want to set

  • 0

Hi I am fetching data for List View from web and want to set Height of List View according to data no of elements in List View are not fix, so I am trying below code but its gives error at run time, so any one can help me to solve this problem, thanks

you can see my xml file here

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:id="@+id/sos_scroll"
    android:layout_above="@+id/last_lin" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@+id/date"
    android:layout_marginTop="5dip" android:fadingEdge="none"
    android:scrollbars="none">

    <RelativeLayout android:layout_width="fill_parent"
        android:id="@+id/sos_rel" android:layout_height="wrap_content"
        android:orientation="vertical">

        <ListView android:paddingLeft="1dip" android:scrollbars="none"
            android:cacheColorHint="#00000000" android:focusable="true"
            android:id="@+id/list" android:dividerHeight="2dip"
            android:layout_below="@+id/date" android:footerDividersEnabled="false"
            android:headerDividersEnabled="false" android:layout_marginRight="12dip"
            android:listSelector="@android:color/transparent"
            android:background="@drawable/newshape_list"
            android:layout_marginLeft="12dip" android:paddingRight="1dip"
            android:layout_height="wrap_content" android:layout_width="fill_parent"
            android:fadingEdge="none" android:divider="#A9ABAD"></ListView>

        <RelativeLayout android:layout_width="wrap_content"
            android:layout_marginLeft="10dip" android:layout_marginBottom="5dip"
            android:layout_marginRight="10dip" android:layout_height="wrap_content"
            android:layout_below="@+id/list">
            <TableLayout android:layout_width="wrap_content"
                android:id="@+id/add_table" android:layout_centerHorizontal="true"
                android:background="@drawable/listback" android:layout_height="wrap_content"
                android:stretchColumns="1">
                <TableRow android:id="@+id/add_data">
                    <ImageView android:layout_width="wrap_content"
                        android:src="@drawable/addbuttonimage" android:id="@+id/que1"
                        android:layout_height="wrap_content"></ImageView>
                    <TextView android:text="Add New Stress..."
                        android:layout_width="wrap_content" android:textStyle="bold"
                        android:textColor="#000000" android:layout_marginLeft="5dip"
                        android:textSize="15sp" android:layout_height="wrap_content"
                        android:padding="3dip" />
                </TableRow>
            </TableLayout>
        </RelativeLayout>
    </RelativeLayout>
</ScrollView>
<LinearLayout android:id="@+id/last_lin"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:paddingBottom="52dip" android:paddingTop="2dip"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">
    <Button android:layout_width="wrap_content" android:textColor="#FFFFFF"
        android:id="@+id/done" android:textStyle="bold" android:text="Save"
        android:layout_height="wrap_content" android:background="@drawable/savebutton"></Button>
</LinearLayout>

error is here

08-22 11:00:34.930: ERROR/AndroidRuntime(324): Uncaught handler: thread main exiting due to uncaught exception
08-22 11:00:34.959: ERROR/AndroidRuntime(324): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1291)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1238)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:279)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:299)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:893)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.ScrollView.onMeasure(ScrollView.java:276)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:569)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:361)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at  android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:569)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:361)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.View.measure(View.java:7964)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.os.Looper.loop(Looper.java:123)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at java.lang.reflect.Method.invokeNative(Native Method)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at java.lang.reflect.Method.invoke(Method.java:521)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-22 11:00:34.959: ERROR/AndroidRuntime(324):     at dalvik.system.NativeStart.main(Native Method)
  • 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-25T00:31:40+00:00Added an answer on May 25, 2026 at 12:31 am

    Have you thought about creating your ListView completely dynamically? In other words, try programmatically creating your ListView, and then manually add it to your layout.

    Also, is there any reason in particular that you want to specify the ListView height manually? Your ListView will automatically resize itself anyway depending on the amount of data you have, and if you have more data than that could fit on the screen, it will become scrollable.

    Edit

    In reference to your second comment and your included XML layout, here’s what I suggest you do.

    Your XML file should only have one root element (hence why it’s called the root). Currently, you have a ScrollView and a LinearLayout. I suggest you just use a LinearLayout as the root. You can use this as a rough skeleton:

    <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="fill_parent"
      android:layout_width="fill_parent"
      ... >
    
        <ListView
            ...
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:layout_weight="1" />
        <TableLayout
            ...
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:layout_weight="0" />
        <Button
            ...
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:layout_weight="0" />
    
    </LinearLayout>
    

    This layout basically pushes your Button to the very bottom, and your TableLayout to the bottom, but above the Button. Your ListView will take the rest of the space above the the TableLayout. (By the way, a TableRow is basically a specialized LinearLayout. You can simply replace the TableLayout with a horizontal LinearLayout to achieve similar results, unless you plan to add multiple rows to the table and need equal sizing for the columns.)

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

Sidebar

Related Questions

I'm trying to fetch data for my forum's index. Fetching a list of all
I want to fetch data from SQLITE database and display it in a LIST.
I am fetching a set of objects from a Core Data persistent store using
I have a class A which is responsible for fetching data from web services
Hi im trying to solve this problem, I'm fetching data from DB and create
I'm fetching data from all 3 tables at once to avoid network latency. Fetching
I have an App using UITableViews and fetching data from a server. I am
I am developing an iPhone application in which I am fetching data from a
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
i am fetching this data from database : $sql = SELECT * FROM articles

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.