私はこの昨日この質問をしましたが、私はこの問題がはるかに複雑であると書きました。私は非常に混乱しており、ここでは非常によく似た質問がありますが、どちらも私の問題を解決しませんでした。だから、私はリストビューを持っている、すべてのリストビューは、テキストビューとedittextが含まれていますが、edittextだけが重要です。 私がtextviewをクリックすると、テストのためにその内容を記録したいと思います。私の問題は、ユーザーが変更した後、同じことをログに記録した後です。エミュレータでsetTextを使わずに変更すると、何もしません。私はデータベースを持っている、リストビューのすべてにedittext(holder.quant)がある。私はそれを変更した場合、編集内容は更新されません
クラスMyAdapterはArrayAdapter {
LayoutInflater inflat;
ViewHolder holder;
public MyAdapter(Context context, int textViewResourceId,
ArrayList<EachRow> objects)
{
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
inflat=LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if(convertView==null)
{
convertView=inflat.inflate(R.layout.row_checkox, null);
holder=new ViewHolder();
holder.textView=(TextView)convertView.findViewById(R.id.textView111);
holder.image=(ImageView)convertView.findViewById(R.id.imageView111);
holder.quant = (EditText)convertView.findViewById(R.id.quantity);
holder.image.setOnClickListener(CustomList.this);
convertView.setTag(holder);
}
holder=(ViewHolder) convertView.getTag();
holder.textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView tv = (TextView) v ;
String text_of_clicked_textview = tv.getText().toString();
final String[] ddata = text_of_clicked_textview.split(" "); //split the result using the spaces (so you could obtain the name, hotness and the other string you use)
final long yy = Long.parseLong(ddata[0]);
info.open();
info.updateQuan(yy, holder.quant.getText().toString());
Log.i("tagitagi", holder.quant.getText().toString());
info.close();
}
});
EachRow row= getItem(position);
EachRow row2= getItem2(position);
holder.quant.setText(row2.text);
holder.textView.setText(row.text);
NullPointerException
holder.image.setTag(position);
holder.quant.setTag(position);
return convertView;
}
@Override
public EachRow getItem(int position) {
// TODO Auto-generated method stub
return list.get(position);
}
public EachRow getItem2(int position) {
// TODO Auto-generated method stub
return list2.get(position);
}
private class ViewHolder
{
TextView textView;
ImageView image;
EditText quant;
}
}
private class EachRow
{
String text;
boolean checkBool;
}
を拡張し、私はaddTextChangedListenerを試してみましたが、私はのsetTextを使用する場合、それは私にエラーを与えます。それで問題は何ですか?
ありがとうございます!
Ajcodez、これはここで起こっていることですが、私はあなたを理解していません。最後の行にある –
問題は、エミュレータのコンテンツを変更して同じデータを取得したときにログに記録されます。 –
ああ、EditTextのテキストを変更してログに記録すると、同じ結果になります。おそらくあなたの所有者に問題がありますか? – AJcodez