Code example for CheckedTextView

Methods: getText, isChecked

0
 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        CheckedTextView textView = (CheckedTextView) view;
        PumpkinDB pumpkinDB = new PumpkinDB(booksAdapter.getContext());
        Integer id = pumpkinDB.getWishListId(textView.getText().toString());
        if (!textView.isChecked()) {   //save
            pumpkinDB.insertWishListMapping(id, book.getId());
        } else {   //delete 
            pumpkinDB.remvoeWishListMapping(id, book.getId());
        } 
        booksAdapter.notifyDataSetChanged();
    } 
}