2012-03-16 17 views
0

私は、カスタム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); 

項目ではありません誰かが間違っていることを知っていますか?私は項目をフォーカス可能に設定しましたが、クリックすることはできません。助けて!ありがとう!

+0

これは 'onItemClickListener'を実装する必要があります – waqaslam

答えて

0

設定onItemClickListener。このためクリッカブル=「True」を

理由は、あなたは、彼らがイベントをクリックし認識するためにクリック可能である必要はあり行としてこれを入れている場合ということです:

アンドロイドでなければなりません.xmlの中のTextViewを設定します。

+0

私は私のメインコールでもそれを持っていることを意味..まだクリックしない –

0

あなたのアイテムのRelativeLayoutからandroid:focusable = "true"を削除します。私は答えは本当に簡単であると考えているあなたのlistView-

lv.setOnItemClickListener(new OnItemClickListener(){ 

@Override 
    public void onItemClick(AdapterView<?> adapter, View view, int position, 
      long arg3) { 
    }); 
+0

私はそれを行い、それでも動作しませんでした:( –

関連する問題