tejas
tejas

Reputation: 2445

Expand a list view when clicked on an element of it

I am beginner in the android development, can any one tell me how to expand a list when I click on an element of it say an image icon.

Upvotes: 3

Views: 4408

Answers (3)

tejas
tejas

Reputation: 2445

This does it for me, due to privacy I can't write the whole code here

            TextView desc = (TextView) v.findViewById(R.id.editText1);                
            ImageView icon = (ImageView) v.findViewById(R.id.listIcon);
            if (desc.getVisibility() == View.VISIBLE) {
               icon.getLayoutParams().height = heightIcon;
               desc.setVisibility(View.GONE);
            } else {
               icon.getLayoutParams().height = LayoutParams.FILL_PARENT;
               desc.setVisibility(View.VISIBLE);
        }

Now when I click the icon, the text view placed below to it, becomes visible and thus has solved the question.

Upvotes: 2

Vinayak Bevinakatti
Vinayak Bevinakatti

Reputation: 40513

Here is the example code snippet to do it : ExpandableList1.java

You can even find it in your Android SDK folder

Drive:***\***\Android-sdk\samples\android-<apilevel>\ApiDemos\src\com\example\android\apis\view\ExpandableList1.java

Upvotes: 1

Che Jami
Che Jami

Reputation: 5151

Take a look at ExpandableListView and ExpandableListAdapter

Upvotes: 1

Related Questions