OnTouchListener のアイデアについて@ user370305に感謝します。今、それは私のために働いていますsetOnTouchListener()
:
public class AdapterListCards extends CursorAdapter implements View.OnTouchListener {
public AdapterListCards(Context context) {
super(context, null, true);
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (view instanceof EditText) {
EditText editText = (EditText) view;
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
} else {
ViewHolder holder = (ViewHolder) view.getTag();
holder.edtCode.setFocusable(false);
holder.edtCode.setFocusableInTouchMode(false);
}
return false;
}
private class ViewHolder {
TextView txtName;
EditText edtCode;
}
@Override
public View newView(final Context context, Cursor cursor, ViewGroup parent) {
View convertView = LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
final ViewHolder holder = new ViewHolder();
holder.txtName = (TextView) convertView.findViewById(R.id.txt_name);
holder.edtCode = (EditText) convertView.findViewById(R.id.pass);
holder.edtCode.setOnTouchListener(this);
convertView.setOnTouchListener(this);
convertView.setTag(holder);
return convertView;
}
@Override
public void bindView(View view, Context context, Cursor cur) {
ViewHolder holder = (ViewHolder) view.getTag();
if (cur!=null) holder.txtName.setText(cur.getString(cur.getColumnIndex("name")));
}
}
もちろんandroid:windowSoftInputMode="adjustPan"
、マニフェスト内のアクティビティについても。