First of all, pardon the broken english.
I want to know how to delete an item when the data is from other class using a delete button inside the listview.
I use a button in MainActivity that will insert some data to array called nicknames.
This is my CustomAdapter class.
public class CustomAdapter extends ArrayAdapter<String>{
public CustomAdapter(Context context, String[] name) {
super(context,R.layout.custom_row ,name);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
final View customView = inflater.inflate(R.layout.custom_row, parent, false);
final String singleName = getItem(position);
TextView nickname = (TextView) customView.findViewById(R.id.nickname);
nickname.setText(singleName);
return customView;
}}
And this is my onClick in MainActivity class
public void resultNickname(View view){
nicknames[] = dbHandler.retrieveName();
setContentView(R.layout.nickname_list);
ListAdapter listAdapter = new CustomAdapter(this,nicknames);
ListView nameListView = (ListView) findViewById(R.id.nickList);
nameListView.setAdapter(listAdapter);
}
I think my problem can be resolved based on this question answer. android: how to delete a row from a ListView with a delete button in the row But i cant make it work because i didnt understand what is the item mean and how to implement it in my code.
Can someone help me at least explaining the items mean from the other question and how to implement it in my code ?