单击编辑按钮时,所有项目名称、描述、价格都进入带有自定义列表视图的编辑文本。我无法在编辑文本中输入任何内容。如果我单击编辑文本,它会显示应用程序没有响应错误。
//my code getview method in Base adapter
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.editappetisesrlistview, null);
holder.caption = (EditText) convertView
.findViewById(R.id.editappetisertext);
holder.price=(EditText)convertView.findViewById(R.id.editappetiserprice);
holder.desc=(EditText)convertView.findViewById(R.id.editappetiserdesc);
holder.caption1=(ImageView) convertView.findViewById(R.id.editappetiserimage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//Fill EditText with the value you have in data source
holder.caption.setText(itemnames[position]);
holder.price.setText(prices[position]);
holder.desc.setText(descs[position]);
holder.caption.setId(position);
holder.price.setId(position);
holder.desc.setId(position);
holder.caption.setFocusableInTouchMode(true);
holder.price.setFocusableInTouchMode(true);
holder.desc.setFocusableInTouchMode(true);
holder.caption1.setImageBitmap(bmps[position]);
//we need to update adapter once we finish with editing
holder.caption.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus)
{
final int position = v.getId();
final EditText Caption = (EditText) v;
Caption.setFocusable(true);
holder.caption.setFocusable(true);
arr.remove(holder.caption.getId());
arr.add(holder.caption.getId(),holder.caption.getText().toString());
}
}
});
holder.price.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus)
{
final int position = v.getId();
final EditText Caption1 = (EditText) v;
// Caption1.setFocusable(true);
holder.price.setFocusable(true);
arr.remove(holder.price.getId());
arr.add(holder.price.getId(),holder.price.getText().toString());
}
holder.desc.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus)
{
final int position = v.getId();
final EditText Caption2 = (EditText) v;
// Caption2.setFocusable(true);
holder.desc.setFocusable(true);
arr.remove(holder.desc.getId());
arr.add(holder.desc.getId(),holder.desc.getText().toString());
}
}
});
}
});
return convertView;
}
}
viewholder.java
class ViewHolder {
EditText caption,price,desc;
ImageView caption1;
}
class ListItem {
String caption;
}
请帮忙