2011-07-16 10 views
0

ListView公式チュートリアル - [url] http://developer.android.com/resources/tutorials/views/hello-listview.html [/ url]に従っていたので、私は、Webサービスを介してエントリをdinamically取得します。ListView(Android)でチェックボックスを配置する方法

問題は、私はそれにチェックボックスを配置したいです。私は

//setListAdapter(new ArrayAdapter<String>(this, R.layout.lista, aux)); 
     setListAdapter(new ArrayAdapter<CheckBox>(this,R.layout.row, convertToListItem(aux))); 

     //ListView lv = getListView(); 
     //lv.setTextFilterEnabled(true); 

この

(AUX(String []型AUX)は以前、正しくこの前fullfilledされる)があると私はこの問題は私のrow.xmlに

<CheckBox xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:textSize="14sp" android:typeface="normal" android:textStyle="normal" 

    android:layout_weight="0" android:layout_gravity="left" /> 

かであると思いますこの関数

private List<CheckBox> convertToListItem(String[] aux2){ 

     List<CheckBox> result = new ArrayList<CheckBox>(); 
     ArrayList<CheckBox> boxes = new ArrayList<CheckBox>(); 

     for (String text : aux2){ 
      CheckBox temp = new CheckBox(this); 
      temp.append(text); 
      temp.setText(text,BufferType.NORMAL); 
      result.add(temp); 
      boxes.add(temp); 

     } 

     return result; 

どうなりますか:チェックボックスが表示されますが、代わりに正しいテキストが表示されます。梨 "android.widget.Checkbox @ ...."

私は間違っていますか?

答えて

1

あなたはArrayAdapterを拡張し、独自のアダプタを実装し、あなたのrow.xml

次にあなたがgetViewメソッドからビュー()メソッドを処理しなければならない中でのTextViewを配置する必要があります。

これが役立つかどうか教えてください。必要でない場合は、もっとコードを追加してください。

関連する問題