Posts

Showing posts from March 30, 2019

Implement SharedPreference in getview

Image
-1 How can I implement SharedPreference in my Adapter class? I want to use it for persisting CheckBox state. Now the CheckBox value unchecks itself when I change Activity or add a new item in the ListView . public class listItems extends ArrayAdapter<Items> { Activity context; List<Items> listitems; public listItems(Activity context, List<Items> listitems) { super(context, R.layout.list_items, listitems); this.context = context; this.listitems = listitems; } @NonNull @Override public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View listViewItem = inflater.inflate(R.layout.list_items, null, true); final Items items = listitems.get(position); ...