在列表项中,有一个“删除”按钮和文本视图。单击列表项中的删除按钮时,我正在删除该特定列表项。但我的问题是:删除按钮在开始时和用户单击时是不可见的在屏幕顶部下方显示的“编辑”按钮上,我想让所有按钮从不可见变为可见..但我不知道如何实现..
ListViewAdapter.java:
public class ListViewAdapter extends BaseAdapter {
public ArrayList<String> list;
Context context;
private LayoutInflater mInflater;
int count = 0;
static int list_size;
public ListViewAdapter(Context context, ArrayList<String> list) {
super();
this.context = context;
this.list = list;
mInflater = LayoutInflater.from(context);
list_size = list.size();
}
public int getCount() {
if (list == null) {
return 0;
} else {
return list_size;
}
}
@Override
public Object getItem(int position) {
Log.i("Calling getItem()", "getItem()");
return list.get(position);
}
@Override
public long getItemId(int position) {
Log.i("Calling getItemId()", "getItemId()");
return position;
}
static class ViewHolder {
TextView notes_text;
static Button delete;
}
// @Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.i("ListViewAdapter is calling...", "calling...");
ViewHolder holder;
Log.i("View to be converted", "" + convertView);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.simplerow, null);
Log.i("View to be converted", "" + convertView);
holder = new ViewHolder();
holder.notes_text = (TextView) convertView.findViewById(R.id.rowTextView);
holder.delete = (Button) convertView.findViewById(R.id.btn_minus);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.notes_text.setText((String) list.get(position));
holder.delete.setTag((Integer) position);
holder.delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Integer myIntegerObject = new Integer((Integer) view.getTag());
Log.i("Integer postioton", "" + myIntegerObject.intValue());
list.remove(list.indexOf(list.get(myIntegerObject.intValue())));
list_size = list.size();
notifyDataSetChanged();
}
});
return convertView;
}
}