У меня есть пользовательский CursorAdapter, и это выглядит как:Почему мой список не доступен?
public class LabelAdapter extends CursorAdapter {
Context con;
LayoutInflater mFactory;
public AlarmTimeAdapter(Context context, Cursor c) {
super(context, c);
con = context;
mFactory = LayoutInflater.from(con);
}
@Override
public void bindView(View view, final Context context, Cursor cursor) {
final String label2 = cursor.getString(AlarmData.ALARM_TITLE_INDEX);
..code to fill in the textview with whats in the cursor
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View ret = mFactory.inflate(R.layout.item_lv, parent, false);
return ret;
}
}
мой item_lv выглядит следующим образом:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:focusable="true"
>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
Когда я зову:
ListView lv = (ListView)findViewById(R.id.listview); //Listview is in the main.xml file
lv.setAdapter(new LabelAdapter(this, mCursor);
lv.setFocusable(true);
Элементы в ListView не являются выбирается .. кто-нибудь знает, что не так? Я установил элементы с возможностью фокусировки, но их нельзя нажать. Помогите! Благодаря!
Для этого вам нужно реализовать 'onItemClickListener' – waqaslam