我从数据库获取menunames然后附加到自定义listview edittext。现在我在edittext中更改一些值。我希望所有值都将edittext的值更改为数组
Example :x,y,z menunames comes from database i append editext(Custom listview)
now i am changed y to b
now i want x,b,z in arraylist
我尝试此代码(基本适配器类)
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.editmainmenulist, null);
holder.caption = (EditText) convertView
.findViewById(R.id.editmaimenu);
holder.caption1=(ImageView) convertView.findViewById(R.id.menuimage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//Fill EditText with the value you have in data source
holder.caption.setText(itemnames[position]);
holder.caption.setId(position);
holder.caption1.setImageBitmap(bmps[position]);
arr.add(holder.caption.getText().toString());//here i get menunames data only not changed edittext values
return convertView;
}
}
class ViewHolder {
EditText caption;
ImageView caption1;
}
class ListItem {
String caption;
}
请帮帮我
答案 0 :(得分:0)
将数据保存在arraylist中并在更改arraylist中的文本后再次使用适配器调用listview,如下所示
lv.invalidate(); // it will rebuilt all the views in listview
adapter=new adapterclass(this);
lv.setAdapter(adapter);
它将更改listview的值并调用listview的invalidateview方法,它将更改listview的数据。试试吧。它可能对你有帮助。
答案 1 :(得分:0)
如果新数据来自数据库,则必须再次调用光标。 setAdapter再次到listView ..
或者如果数据已经在数组列表中,那么您只是用来使listView无效。 n再次设置适配器.... 你会得到你想要的......