0
나는 목록이 컨텍스트 메뉴에 등록되어있는 SimpleCursorAdapter
를 사용하여 목록보기를 만드는거야 ... 다음은 업데이트 목록 항목은
registerForContextMenu(listView);
이 내 전체 목록을 업데이트 onContextItemSelection
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (menuItemIndex) {
case 0:{
//perform some action
//then update the adapter
Cursor newCursor = fetchNewCursor();
if(newCursor .moveToFirst()){
adapter.swapCursor(newCursor);
adapter.notifyDataSetChanged();
}//if ends
}// case 0 ends
break;
}//switch ends
}//onContextItemSelected() ends
입니다 onContextItemSelected 보기, 특정 목록 항목 만 (길게) 클릭 만 업데이트하려는 다른 context menu
항목을 추가하고 싶습니다. 내가 그렇게 할 수있는 방법 ...
이 내 Cursor Adapter
이
@Override
public View newView (Context context, Cursor cursor, ViewGroup parent) {
return viewInflater.inflate(layout, null);
}
같은 외모와 bindView
방법
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
TextView t1=(TextView)view.findViewById(R.id.txt_one);
TextView t2=(TextView)view.findViewById(R.id.txt_two);
t1.setText(cursor.getString(...));
t2.getString(cursor.getString(...));
}
관련
어떤'lv.getSelectedItem(); '반환을? – dakait
어댑터에서 ArrayAdapter을 설정하면 getSeletedItem이 선택한 인덱스에서 항목을 반환합니다. –
메신저 ArrayAdapter를 사용하고 있지 않습니다. 어댑터가'public class MyListAdapter extends SimpleCursorAdapter {'아이템을 얻은 후 어떻게 보이나요? 텍스트 뷰를 어떻게 얻을 수 있습니까? – dakait