-1
목록 어댑터를 통해 채울 목록보기에 EditText가 있습니다. 내 문제는 EditText에 텍스트를 입력하고 뒤로 버튼을 누르면 모든 변경 사항이 손실되지만 다른 항목은 잃어 버리게됩니다. 일부 다른 위치 (ListView가없는 곳)에서 EditText가 제대로 작동합니다 (모든 변경 사항이 유지됩니다). 왜 이런 일이 벌어지고 어떻게이 문제를 해결할 수 있습니까?안드로이드 : 뒤로 버튼을 눌렀을 때 Textedit 입력이 손실되었습니다
글고 코드 >>
<EditText
android:id="@+id/edit_card_list_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/editbox_cursor_margin"
android:layout_marginRight="@dimen/editbox_cursor_margin"
android:layout_marginTop="@dimen/edit_card_list_mid_gap"
android:background="@color/white"
android:ems="10"
android:enabled="true"
android:fontFamily="@string/roboto_light_font"
android:inputType="textNoSuggestions"
android:textSize="@dimen/forty_eight_font" >
</EditText>
Listadapter 코드 >>
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
boolean convertViewWasNull = false;
if(rowView == null){
rowView = inflator.inflate(R.layout.edit_card_list_layout, parent, false);
convertViewWasNull = true;
}
TextView titleview = (TextView) rowView.findViewById(R.id.edit_card_list_title);
EditText detailview = (EditText) rowView.findViewById(R.id.edit_card_list_editText);
if(title.get(position) != null){
titleview.setText(title.get(position).toString());
}
if(detail.get(position) != null){
detailview.setText(detail.get(position).toString());
}else{
detailview.setText("");
}
detailview.requestFocus();
//InputMethodManager inputManager = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
//inputManager.restartInput(detailview);
if(convertViewWasNull){
detailview.addTextChangedListener(new GenericTextWatcher(detailview));
}
detailview.setTag(title.get(position).toString());
return rowView;
}
private class GenericTextWatcher implements TextWatcher{
private EditText view;
private GenericTextWatcher(EditText view) {
this.view = view;
}
public void afterTextChanged(Editable editable) {
text = editable.toString();
//save the value for the given tag :
EditCardListAdapter.this.editTextValues.put((String) view.getTag(),text);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
}