我一直面临着从列表视图中删除使用片段中的自定义适配器的项目的问题,请提出一些建议
listview = (ListView) v.findViewById(R.id.listview);
CustomAdapter customAdapter = new CustomAdapter();
listview.setAdapter(customAdapter);
return v;
}
class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return phno.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int i, View view, ViewGroup parent) {
view = getLayoutInflater().inflate(R.layout.listview_layout,
null);
Button btn =(Button) view.findViewById(R.id.cancel_button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listview.removeViewAt(i);
notifyDataSetChanged();
}
});
return view;
}
应用程序通过单击“取消”按钮关闭