I'm creating a custom list view that is able to add or remove items. I try this code to add a new row item to list view but it says "The method add(String) is undefined for the type ListView".
This is my code:
public class AddActivityCustomList extends ArrayAdapter<String> {
private final Activity context;
private final String[] web;
public AddActivityCustomList(Activity context, String[] web) {
super(context, R.layout.add_activity_single_list, web);
this.context = context;
this.web = web;
}
public View getView(final int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.add_activity_single_list,
null, true);
TextView txtTitle = (TextView) rowView
.findViewById(R.id.act_title_single);
txtTitle.setTypeface(myface);
txtTitle.setText(web[position]);
return rowView;
}
And my Add Button code is this:
add_activity.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
lv.add(add_act_title.getText().toString());
add_act_title.setText("");
adapter.notifyDataSetChanged();
add_act_title.getText();
}
});
that has problem in lv.add(...
part.What should I do?