2010-10-12 2 views

ответ

1

Я использовал следующие производить то, что изображено на картинке:

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" /> 

Это то, что я получаю: Context menu alert dialog

+0

ответ неверен, потому что вопрос задает список из нескольких элементов (изображение + текст). В любом случае, благодарю Вас! – MoHaKa

Смежные вопросы