我从数据库中获取项目名称并附加到自定义列表视图中的编辑文本。现在我正在更改edittext中的值我可以打印我正在打印的内容我想要存储一个变量
我的代码:
public View getView(int position, View convertView, ViewGroup parent) {
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]);
//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;
itemnames[position] = Caption.getText().toString();
System.out.println(Caption.getText().toString());//here only i am printing all values i want store all values into one varible
}
}
});
return convertView;
}
}