コード例 #1
0
  protected void onListItemClick(ListView l, View v, int position, long id) {
    Cards currCard = (Cards) getListView().getItemAtPosition(position);

    Intent intent = new Intent(this, ViewCards.class);

    Bundle bundle = new Bundle();
    bundle.putString(ViewDecks.DECK_TITLE, deck.getName());
    bundle.putString(ViewCards.FRONT_OF_CARD, currCard.getFront());
    bundle.putString(ViewCards.BACK_OF_CARD, (String) currCard.getBack());
    intent.putExtras(bundle);

    startActivity(intent);
  }
コード例 #2
0
 public boolean onContextItemSelected(MenuItem item) {
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   Cards currCard = (Cards) getListView().getItemAtPosition(info.position);
   switch (item.getItemId()) {
     case R.id.edit:
       Intent intent = new Intent(this, AddCards.class);
       Bundle bundle = new Bundle();
       bundle.putString(DECK_TITLE, deck.getName());
       bundle.putString(AddCards.OLD_CARD_FRONT, currCard.getFront());
       bundle.putString(AddCards.OLD_CARD_BACK, (String) currCard.getBack());
       intent.putExtras(bundle);
       startActivityForResult(intent, EDIT_CARD);
       return true;
     case R.id.delete:
       deck.deleteCard(currCard.getFront());
       backend.save(deck);
       cards = deck.getCards();
       listView.setAdapter(new ArrayAdapter<Cards>(this, R.layout.card, cards));
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }