2011-10-31 17 views
2

これは私の最初のAndoidアプリケーションです。私はListViewに複数の選択肢を実装することはできません(リストビューの各行にチェックボックスが必要です)。 私はnotepadv3チュートリアルを使用しています。 誰かが私を助けることができる、私はJavaの初心者です。Listviewの各行にチェックボックスを実装する方法

private void fillData() { 
    ListView lView = (ListView) findViewById(android.R.id.list); 
    // Get all of the notes from the database and create the item list 
    //lView = (ListView) findViewById(R.id.liste); 
    Cursor c = mDbHelper.fetchAllNotes(); 
    startManagingCursor(c); 
    String[] from = new String[] { NotesDbAdapter.KEY_TITLE }; 
    int[] to = new int[] { R.id.text1 }; 
    // Now create an array adapter and set it to display using our row 
    SimpleCursorAdapter notes = 
     new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); 
    setListAdapter(notes); 

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

<ListView 
android:id="@+id/android:list" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" /> 


<CheckBox android:text="" 
    android:id="@+id/list_checkbox" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:checked="false" 
    /> 

<TextView android:id="@id/android:empty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/no_notes"/> 

答えて

1

あなたは、XMLレイアウトR.layout.notes_rowのチェックボックスを含める必要があります。 XMLコードを投稿すると、より多くの情報を得ることができます。 SOで

+0

notes_row xmlのチェックボックスを実装できません – Ertan

+0

どういう意味ですか? –

+0

それは動作し、それはとても簡単だった:) thx – Ertan

関連する問題