1
setListAdapter(new ArrayAdapter<String>(this,R.layout.custom_list_item, r));

protected void onListItemClick(ListView list, View view, int position, long id) {
                super.onListItemClick(list, view, position, id);

                    fname=r.get(position);

上記のコードは、配列アダプターからも位置と名前を取得しました

同様に、これらすべてを取得する必要がありますコンテキストメニューの値はどうすれば取得できますか

 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.setHeaderTitle("Playlist Option");
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.context_menu, menu);    

    }   

 public boolean onContextItemSelected(MenuItem item) {

// here I select the particular list value, that the value position I need that is only I delete that position from server. what are the data i fetch here? and its possible to get position from array list? 
}           
4

2 に答える 2

2

使用できますAdapterContextMenuInfo

public boolean onContextItemSelected(MenuItem item) {
     AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

     switch (item.getItemId()) {
        case R.id.delete:
            String itemName = r.get[(int) info.id]; // This item you will delete
                                                    // from list
            return true;


        }
    }
于 2012-06-19T04:56:24.443 に答える