SQLITE クエリから SimpleCursorAdapter を使用して入力された TextView と Editview を持つ単純なリストビューがあります。簡単な検証を行ってデータベースを更新できるように、ユーザーがいつ EditView を離れたかを把握しようとしています。これを行うために他の投稿で提案されているいくつかの方法を試しましたが、イベントをキャッチできません。以下に、これを行うために私が試みた2つの異なる方法を示します。助けてください。大変ありがたく存じます。
private void showClasses(Cursor cursor) {
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.classrow, cursor, FROM, TO);
setListAdapter(adapter);
adapter.notifyDataSetChanged();
//ATTEMPT 1
for (int i = 0; i < adapter.getCount(); i++){
EditText et = (EditText) adapter.getView(i, null, null).findViewById(R.id.classpercentage);
et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
Log.d("TEST","In onFocusChange");
}
});
//METHOD 2
et.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
Log.d("TEST","In afterTextChanged");
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){Log.d("TEST","In beforeTextChanged");}
public void onTextChanged(CharSequence s, int start, int before, int count){Log.d("TEST","In onTextChanged");}
});
}
}
LogCat に何も表示されず、デバッガーのブレークポイントがヒットしません。