在android中单击图像时显示下拉列表

在android中单击图像时显示下拉列表,android,Android,在我的android应用程序中,我显示了不同类别的图片。当我点击这些图片时,我想得到一个特定类别中项目的小列表。 我不确定哪个控件可以满足这个要求,我如何使用它 谁能给我一个解决方案吗 请分享你的宝贵建议 提前感谢:)使用带光标或适配器的ExpandableListView。组视图可以是您的图像,子视图可以是文本 布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://sche

在我的android应用程序中,我显示了不同类别的图片。当我点击这些图片时,我想得到一个特定类别中项目的小列表。 我不确定哪个控件可以满足这个要求,我如何使用它

谁能给我一个解决方案吗

请分享你的宝贵建议


提前感谢:)

使用带光标或适配器的ExpandableListView。组视图可以是您的图像,子视图可以是文本

布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <ExpandableListView android:id="@id/android:list"
  android:layout_width="fill_parent" android:layout_height="wrap_content" />
 <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:gravity="center"
  android:layout_height="wrap_content" android:text="Sorry, no data" />
</LinearLayout>

public class myListy extends ExpandableListActivity {

 Cursor mCursor;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  // Define group data in mCursor
  startManagingCursor(mCursor);

 ExpandableListView mExpandableListView = (ExpandableListView) findViewById(android.R.id.list);
  mExpandableListView.setGroupIndicator(null);

EAdapter adapter = new EAdapter(mCursor, getApplicationContext());
  mExpandableListView.setAdapter(adapter);
}

private class EAdapter extends CursorTreeAdapter {

  public EAdapter(Cursor cursor, Context context) {
   super(cursor, context);
  }

  @Override
  protected void bindChildView(View view, Context context, Cursor cursor,
    boolean isLastChild) {

   // Add your data to the child.

  }

  @Override
  protected void bindGroupView(View view, Context context, Cursor cursor,
    boolean isExpanded) {

   // Add your data to the group.

  }

  @Override
  protected View newChildView(Context context, Cursor cursor,
    boolean isLastChild, ViewGroup parent) {

   View view = getLayoutInflater().inflate(
     R.layout.text_layout, null);

   return view;
  }

  @Override
  protected View newGroupView(Context context, final Cursor cursor,
    boolean isExpanded, ViewGroup parent) {

                                View view = getLayoutInflater().inflate(
     R.layout.images_layout, null);

   return view;
  }

  @Override
  protected Cursor getChildrenCursor(Cursor groupCursor) {
                        // data for childern 

   return cursor;
  }
 }

公共类MyList扩展了ExpandableListActivity{
光标mCursor;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//在mCursor中定义组数据
开始管理光标(mCursor);
ExpandableListView mExpandableListView=(ExpandableListView)findViewById(android.R.id.list);
mExpandableListView.setGroupIndicator(空);
EAdapter adapter=新的EAdapter(mCursor,getApplicationContext());
setAdapter(适配器);
}
私有类EAdapter扩展了CursorTreeAdapter{
公共EAdapter(光标、上下文){
超级(光标、上下文);
}
@凌驾
受保护的void bindChildView(视图视图、上下文上下文、光标、,
布尔值(isLastChild){
//将数据添加到子级。
}
@凌驾
受保护的void bindGroupView(视图视图、上下文上下文、光标、,
布尔值(扩展){
//将您的数据添加到组中。
}
@凌驾
受保护视图newChildView(上下文、光标、,
布尔值isLastChild,视图组父级){
视图=GetLayoutFlater()。充气(
R.layout.text_布局,空);
返回视图;
}
@凌驾
受保护视图newGroupView(上下文上下文、最终光标、,
布尔值(isExpanded,视图组父级){
视图=GetLayoutFlater()。充气(
R.layout.images\u布局,空);
返回视图;
}
@凌驾
受保护的游标getChildrenCursor(游标组游标){
//儿童数据
返回光标;
}
}

谢谢Sameer。你能告诉我如何使用它吗?如果你有任何示例代码:)Sameer如果我使用这个可扩展列表,图像也应该放在列表中。但我要找的是,我将图像放在videoplayer顶部的一行中。更清楚地说,我在videoplayer顶部有不同系列的图像。如果用户单击任何图像,该图像的子列表应在图像正下方的同一页面中可见。any how感谢Sameer为您提供响应使用图库获取顶级图像。创建一个包含列表的POP窗口