Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1.     @Override
  2.     public void bindView(View view, Context context, final Cursor cursor) {
  3.         TextView tvSelectedAllergy = (TextView) view.findViewById(R.id.tvSelectedAllergy);
  4.         ImageButton bDeleteSelectedAllergy = (ImageButton) view.findViewById(R.id.bDeleteSelectedAllergy);
  5.         tvSelectedAllergy.setText(cursor.getString(cursor.getColumnIndex(PrepopulatedDatabase.ALLERGY_KEY_NAME)));
  6.  
  7.         bDeleteSelectedAllergy.setOnClickListener(new ImageButton.OnClickListener() {
  8.             @Override
  9.             public void onClick(View v) {
  10.                 //Whenever I click an item in the list it just deletes the last one. I guess because the cursor is at the last position? But still... shouldn't this add a new OnClickListener for each item in the list with the data from the cursor at the runtime?
  11.                 ppd.deleteItem(PrepopulatedDatabase.ALLERGY_TABLE, PrepopulatedDatabase.KEY_ID, cursor.getString(cursor.getColumnIndex(PrepopulatedDatabase.KEY_ID));
  12.             }
  13.         });
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement