Search code examples
androidlistviewexpand

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.


Solution

  • 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.