Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ListAdapter adapter = new SimpleAdapter(
  2. AllProductsActivity.this, productsList,
  3. R.layout.list_item, new String[] { TAG_ID,
  4. TAG_NAME, TAG_DATA, TAG_DATA2, TAG_QTD},
  5. new int[] { R.id.id, R.id.descricao, R.id.data, R.id.data2, R.id.qtd});
  6. // updating listview
  7. setListAdapter(adapter);
  8. }
  9. });
  10.  
  11. }
  12.  
  13. }
  14.  
  15. @Override
  16. public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
  17. getMenuInflater().inflate(R.menu.context, menu);
  18. }
  19.  
  20. public boolean onContextItemSelected(MenuItem item) {
  21. AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  22. switch(item.getItemId()) {
  23. case R.id.item1:
  24. long id = getListAdapter().getItemId(info.position);
  25.  
  26. Toast.makeText(getApplicationContext(),String.valueOf(id),
  27. Toast.LENGTH_SHORT).show();
  28. return true;
  29. case R.id.item2:
  30.  
  31. return true;
  32. default:
  33. return super.onContextItemSelected(item);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement