I have tried reading the documentation on it and I understand that I need to use removeValue() to accomplish this, I just don't know how to get the position of the click. I am pulling the list down from firebase and trying to use an OnItemClick() to say anytime something in the listview is clicked, it will be deleted. I feel like this is super simple and I'm just missing something.
public class DeleteChoiceListFragment extends Fragment {
DatabaseReference mRootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference mRestReference = mRootRef.child("restaurants");
List<String> listofrest = new ArrayList<String>();
ListView restaurantListView;
ListAdapter restaurantListAdapter;
public DeleteChoiceListFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.restaurant_selection_list_frag,container,false);
restaurantListView = (ListView) view.findViewById(R.id.restaurantListView);
restaurantListAdapter = new FirebaseListAdapter<Restaurants>(getActivity(),Restaurants.class,R.layout.individual_restaurant_name_nocheckbox,mRestReference) {
@Override
protected void populateView(View v, Restaurants model, final int position) {
TextView restName = (TextView) v.findViewById(R.id.restname);
restName.setText(model.getName());
listofrest.add(position,model.getName());
}
};
restaurantListView.setAdapter(restaurantListAdapter);
restaurantListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}
});
return view;
}
}
Going on 36 hours of no sleep now so my brain is 100% dead. I can provide more detail if necessary