amol chavan
amol chavan

Reputation: 21

ExpandableListView in Android

I have requirement like this- my activity contains some textviews at the top then the expandable list view in the middle and a button at the bottom. my problem is when i clicked on
expandable list view the expanded list get accommodated in the space between button and expandable list view.

I wanted expandable list view to get expanded full and button should move downward according to the contains of the expandable list view. And i have used scrollview as a main layout.
thank you

Upvotes: 2

Views: 2102

Answers (4)

Kirit  Vaghela
Kirit Vaghela

Reputation: 12664

Custom ExpandableListView Tutorial

http://www.mysamplecode.com/2012/10/android-expandablelistview-example.html

Upvotes: 0

Tai Tran
Tai Tran

Reputation: 1406

You should place your expandable Listview and your button in a relative layout, and set align below is your button, It works for me.

Upvotes: 0

drink_android
drink_android

Reputation: 151

Instead of using ScrollView as the main layout, use a LinearLayout but without the Button. For eg:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <ExpandableListView
            android:id="@+id/expandableListView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </ExpandableListView>

    </LinearLayout>

Now in code, add the Button as the footerView of the ExpandableListView as :

final ExpandableListView elv = (ExpandableListView) findViewById(R.id.expandableListView1);
Button btn = new Button(this);
elv.addFooterView(btn); 

The button will always be present at the end of the ExpandableListView using this. Just as you want it to be.

Upvotes: 0

fedj
fedj

Reputation: 3452

Is this a LinearLayout with android:layout_weight attributes ?

Upvotes: 1

Related Questions