Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在alertdialog中列出多个项目(图像和文本)_Android_List_Android Alertdialog - Fatal编程技术网

Android 如何在alertdialog中列出多个项目(图像和文本)

Android 如何在alertdialog中列出多个项目(图像和文本),android,list,android-alertdialog,Android,List,Android Alertdialog,嗨。。 我想做这种对话 你能帮我找到解决办法吗??? 谢谢你D给你:我使用以下内容来生成图像中所示的内容: Cursor books = ((Activity)ctx).managedQuery(booksprovider.CONTENT_URI_BOOKS, null, dbhelper.BOOKS_COLLECTION + " = ? AND "+ dbhelper.BOOKS_SHELF +" != ?", new String[]{ Strings.Libr

嗨。。 我想做这种对话

你能帮我找到解决办法吗???
谢谢你D

给你:

我使用以下内容来生成图像中所示的内容:

 Cursor books = ((Activity)ctx).managedQuery(booksprovider.CONTENT_URI_BOOKS, null, 
            dbhelper.BOOKS_COLLECTION + " = ? AND "+ dbhelper.BOOKS_SHELF +" != ?", new String[]{ Strings.Library, String.valueOf(ShelfId) }, 
            dbhelper.BOOKS_ID+" DESC");
    final ListView booksToAdd = new ListView(ctx);

    SimpleCursorAdapter booksList = new dialogView(ctx, R.layout.shelves_add, books,
            new String[] { dbhelper.BOOKS_TITLE, dbhelper.BOOKS_AUTHOR },//columns to include in view 
            new int[] { R.id.search_results_title,  R.id.search_results_author }, ShelfId );//views to bind columns to

    booksToAdd.setAdapter(booksList);
    booksToAdd.setClickable(true);
    alert.setView(booksToAdd);
    alert.setPositiveButton("Finished", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ((shelves)context).adapter.notifyDataSetChanged();
        }
    }).show();

 R.layout.shelves_add contains the following:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/solid_white"
android:padding="0dp" >
<ImageView
    android:id="@+id/img"
    android:layout_width="18dp"
    android:layout_height="32dp"
    android:layout_marginTop="15dp"
    android:layout_marginRight="6dp"
    android:layout_marginLeft="6dp"
    android:contentDescription="@string/imagedescrip"
    android:layout_toLeftOf="@+id/search_results_title"
    android:src="@drawable/book_tab" />

<TextView
    android:id="@+id/search_results_title"
    android:layout_width="260dp"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="0dp"
    android:textColor="@drawable/solid_black"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="60dp"/>

<TextView
    android:id="@+id/search_results_author"
    android:layout_width="260dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/search_results_title"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="10dp"
    android:paddingBottom="18dp"
    android:textColor="@drawable/solid_black"
    android:textSize="12dp" />

<CheckBox
    android:id="@+id/selected_box"
    android:layout_width="20dip"
    android:layout_height="20dip"
    android:layout_alignRight="@+id/search_results_title"
    android:layout_centerVertical="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dp"
    android:background="@drawable/checkbox" />
Cursor books=((活动)ctx).managedQuery(booksprovider.CONTENT\u URI\u books,null,
dbhelper.BOOKS_COLLECTION+“=”和“+dbhelper.BOOKS_SHELF+”!=?”,新字符串[]{Strings.Library,String.valueOf(ShelfId)},
dbhelper.BOOKS_ID+“DESC”);
最终ListView booksToAdd=新ListView(ctx);
SimpleCursorAdapter booksList=新建对话框视图(ctx、R.layout.sheels\u添加、书籍、,
新字符串[]{dbhelper.BOOKS\u TITLE,dbhelper.BOOKS\u AUTHOR},//要包含在视图中的列
新int[]{R.id.search_results_title,R.id.search_results_author},ShelfId)//要将列绑定到的视图
booksToAdd.setAdapter(booksList);
booksToAdd.setClickable(真);
alert.setView(booksToAdd);
alert.setPositiveButton(“完成”,新建DialogInterface.OnClickListener()){
@凌驾
public void onClick(DialogInterface dialog,int which){
((工具架)上下文).adapter.notifyDataSetChanged();
}
}).show();
R.layout.u添加包含以下内容:

这就是我得到的:

您的回答不正确,因为问题询问的是多项目列表(图像+文本)。无论如何,谢谢你!