G
Gingerbread
Fortgeschrittenes Mitglied
- 6
Ich habe eine CheckedTextView in meine ListView mit eingebunden:
Der zugehörige Code:
Der Listener funktioniert einwandfrei. Das Problem ist nun, dass es keine Auswirkung hat, wenn man auf eine der CheckedTextViews klickt. Die CheckedTextViews reagieren (sieht man an der leichten Designänderung), jedoch werden sie nicht ausgewählt. Sprich es erscheint kein grüner Haken darin.
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="310dip"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:orientation="vertical">
<TextView android:id="@+id/auf_datum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dip"/>
<TextView android:id="@+id/auf_inhalt"
android:layout_width="wrap_content"
android:layout_marginBottom="8dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView android:id="@+id/auf_termin"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView android:id="@+id/auf_preis"
android:layout_width="60dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<CheckedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/auf_check"
android:layout_marginRight="10dip"
android:layout_marginTop="15dip"
android:layout_marginLeft="10dip"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:clickable="true"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Der zugehörige Code:
Code:
ListView list = getListView();
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.checked_text_view,
c,
new String[] { "_id", "bemerkung", "termin", "preis" },
new int[]{R.id.auf_datum,R.id.auf_inhalt,R.id.auf_termin,R.id.auf_preis} );
adapter.setViewBinder(new ViewBinder() {
// Daten werden in die einzelnen TextViews geladen.
});
setListAdapter(adapter);
//der Listener:
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(Activity1.this, Activity2.class);
startActivity(i);
}
Der Listener funktioniert einwandfrei. Das Problem ist nun, dass es keine Auswirkung hat, wenn man auf eine der CheckedTextViews klickt. Die CheckedTextViews reagieren (sieht man an der leichten Designänderung), jedoch werden sie nicht ausgewählt. Sprich es erscheint kein grüner Haken darin.