我通过url从服务器数据库获取所有的manunames我使用base adapter将所有menunames附加到editext自定义listview中。现在我将Edittext更改的值转换为列表数组。现在我想要存储edittext所有值,无论他是否更改了menunames.Eg:x,yz ...来自数据库的menunames附加到editext现在我将menuname更改为b并且在editext.now中我想要[x,bc ..]在arraylist中的vaules,但现在我得到了b,c
this is my code
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]);//here only i append database menunames
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();
arr.add(Caption.getText().toString());//here only i think problem..please see any body can tell what i have mistake has been done
}
}
});
return convertView;
}
}
class ViewHolder {
EditText caption;
ImageView caption1;
}
class ListItem {
String caption;
}
我想知道editext值是否发生变化的所有edittext值。为了更新purpous。 我以前可以买到所有的名字。我希望将旧的游戏名称更新为新的游戏名称
答案 0 :(得分:1)
将TextChangedListener
添加到EditText
getView()
<强>代码:强>
holder.caption.addTextChangedListener(new TextWatcher()
{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s)
{
// TODO Auto-generated method stub
String data = holder.caption.getText().toString().trim();
}
});
现在可以根据需要从edittext获取数据,onTextChanged,beforeTextChanged或afterTextChanged ..