私はeditText
を最初の位置でのみ無効にしたいリストビューを持っています。これは私がやったことです:アンドロイドは特定の位置のリストビューでeditTextを無効にします
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final PatientView patientView;
if(convertView==null){
LayoutInflater inflater=LayoutInflater.from(context);
convertView=inflater.inflate(R.layout.lay_add_session_view,null);
patientView=new PatientView();
patientView.edtSessionDescription= (EditText) convertView.findViewById(R.id.edtSessionDescription);
patientView.edtSessionNumber= (EditText) convertView.findViewById(R.id.edtSessionNumber);
patientView.txtSessionTime= (TextView) convertView.findViewById(R.id.txtSessionTime);
patientView.btnAdd= (Button) convertView.findViewById(R.id.btnAdd);
patientView.btnDelete= (Button) convertView.findViewById(R.id.btnDelete);
convertView.setTag(patientView);
} else {
patientView= (PatientView) convertView.getTag();
}
patientView.edtSessionNumber.setText(modelPatientArrayList.get(position).getSessionNumber());
patientView.edtSessionNumber.setTag(position);
patientView.edtSessionDescription.setText(modelPatientArrayList.get(position).getSessionDescription());
patientView.txtSessionTime.setText(modelPatientArrayList.get(position).getTime());
if(0==(Integer)patientView.edtSessionNumber.getTag()){
patientView.edtSessionNumber.setEnabled(false);
}
patientView.btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("tag position",(Integer) patientView.edtSessionNumber.getTag()+"");
updateFirstSession(modelPatientArrayList.get(position), patientView.edtSessionDescription.getText().toString());
modelPatientArrayList.clear();
modelPatientArrayList.addAll(dbUtil.getPatientSession());
patientView.btnAdd.setText("edit");
patientView.btnAdd.setTag(position);
notifyDataSetChanged();
}
});
patientView.btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deleteFromDataBase(modelPatientArrayList.get(position));
modelPatientArrayList.clear();
modelPatientArrayList.addAll(dbUtil.getPatientSession());
notifyDataSetInvalidated();
}
});
return convertView;
}
しかし、問題は、スクロール後に他のビューのedittextを無効にすることです。誰でも私が間違っていることを教えてください。
ありがとう – Shaan