Android-ExpandableListView功能不工作。。

Android-ExpandableListView功能不工作。。,android,android-layout,listview,android-listview,expandablelistview,Android,Android Layout,Listview,Android Listview,Expandablelistview,我想做的是在每个列表视图项中都有一个带有按钮的listview项。 当按下按钮时,我希望一个处于“消失”状态的布局将可见,并随着动画向下展开,如果显示该布局,则当同一按钮被按下时,该布局将向上滑动并再次消失 为此,我为listview项创建了下一个布局- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/androi

我想做的是在每个列表视图项中都有一个带有按钮的listview项。 当按下按钮时,我希望一个处于“消失”状态的布局将可见,并随着动画向下展开,如果显示该布局,则当同一按钮被按下时,该布局将向上滑动并再次消失

为此,我为listview项创建了下一个布局-

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

      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:id="@+id/tilte_info">

        <TextView
            android:id="@+id/textView_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="15dp"
            android:text="TextView"
            android:textSize="20sp" />

        <Button
            android:id="@+id/button_open"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="25dp"
            android:text="Open" />

    </LinearLayout>


     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:background="#5C83AF"
        android:visibility="gone"
        android:id="@+id/extend_info">

        <TextView
            android:id="@+id/textView_more_info"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="15dp"
            android:text="TextView"
            android:textSize="20sp" />



    </LinearLayout>



</LinearLayout>
问题是,我试图调试代码,它进入onclick函数,但什么都没有发生——没有显示的布局

我已经在listview之外用simple textview修改了动画代码,它成功了,但是当我试图在listview项目中使用它时,它不起作用

你知道为什么吗


感谢您提供的任何帮助

使用ExpandableListView。您必须将BaseExpandableListAdapter扩展到适配器并重写方法。在此方法中,重写getGroupView以显示expandablegroup的名称,重写getChildView方法以膨胀列表的子视图。为子视图扩展布局后,在该视图上设置所需的动画。

您应该使用expandableview…
这是一个基本的例子

你必须使用
    public class MainActivity extends Activity {
ArrayList<Place> placesList = new ArrayList<Place>();
placeAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    Place place1 = new Place("Place num 1", "some info on place 1");
    Place place2 = new Place("Place num 2", "some info on place 2");
    Place place3 = new Place("Place num 3", "some info on place 3");

    placesList.add(place1);
    placesList.add(place2);
    placesList.add(place3);

    ListView lv = (ListView) findViewById(R.id.listview_1);

    adapter = new placeAdapter(this);

    lv.setAdapter(adapter);
    }

         class placeAdapter extends ArrayAdapter<Place> implements OnClickListener{

        public placeAdapter(Context context) {
            super(context, -1, placesList);

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            if (convertView==null){
                // use the LayoutInflater to inflate an XML layout file:
                convertView=getLayoutInflater().inflate(R.layout.list_item, parent,false);
            }

            TextView textTitle = (TextView) convertView.findViewById(R.id.textView_title);
            TextView textInfo = (TextView) convertView.findViewById(R.id.textView_more_info);
            Button open = (Button) convertView.findViewById(R.id.button_open);

            infoLayout = (View)  convertView.findViewById(R.id.extend_info);
            infoLayout.setVisibility(View.GONE);
            open.setOnClickListener(this);

            Place place = placesList.get(position);

            textTitle.setText(place.getTitle());
            textInfo.setText(place.getInfo());

        return convertView;
        }

        @Override
        public void onClick(View v) {

            if(infoLayout.isShown()){
                slide_up(MainActivity.this, infoLayout);
                infoLayout.setVisibility(View.GONE);

            }else{
                infoLayout.setVisibility(View.VISIBLE);
                slide_down(MainActivity.this, infoLayout);

            }

        }

        }



     public static void slide_down(Context ctx, View v){

      Animation a = AnimationUtils.loadAnimation(ctx, R.anim.slide_down);
      if(a != null){
         a.reset();
         if(v != null){
          v.clearAnimation();
          v.startAnimation(a);
         }
      }
    }



 public static void slide_up(Context ctx, View v){

      Animation a = AnimationUtils.loadAnimation(ctx, R.anim.slide_up);
      if(a != null){
         a.reset();
         if(v != null){
          v.clearAnimation();
          v.startAnimation(a);
         }
      }
    }






    }