我有一个带有自定义数组适配器的自定义列表视图。我的问题是在单击编辑图像时,我需要在编辑文本上使用相关文本。我搜索了很多,但我无法得到解决方案。
我的代码是:
public class SimpleAdapter1 extends ArrayAdapter<Data> implements OnClickListener {
private ArrayList<Data> items;
Context context;
TextView tv1;
ImageView edit;
ImageView delete;
public SimpleAdapter1(Context context, int textViewResourceId,
List<Data> catDesc) {
super(context, textViewResourceId, catDesc);
this.items = (ArrayList<Data>) catDesc;
this.context = context;
System.out.println(items);
}
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.masterlist, null);
}
Data dt = items.get(position);
if (dt != null) {
tv1 = (TextView) v.findViewById(R.id.mastext1);
if (tv1 != null) {
tv1.setText(dt.getDesc());
}
}
});
tv1.setOnClickListener(this);
edit = (ImageView) v.findViewById(R.id.editImage);
delete = (ImageView) v.findViewById(R.id.deleteImage);
edit.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
}
});
delete.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Toast.makeText(context,
items.get(position).getDesc() + " delete",
Toast.LENGTH_SHORT).show();
}
});
return v;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.mastext1:
break;
}
}
}