How To Maintain Value Of Each Edittext In Customlistview
Good Day, I have a problem with maintaining value on each EditText in a custom listview for example I rotate the screen, each value has gone, Please Help me what approach should I
Solution 1:
add setQuantity and getQuantity (getter-setter method in your PSP model).
String pricex = psp.getQuanntity();
int xx = Integer.parseInt(pricex);
int total = xx + 1;
String totalx = Integer.toString(total);
handler.qty.setText(totalx);
handler.add.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
//add
psp.setQuantity(yourQuantity++);
notifyDataSetChanged();
}
});
handler.minus.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
//add
psp.setQuantity(yourQuantity--);
notifyDataSetChanged();
}
});
I hope it's really help you.
Solution 2:
Hope this will work for you- Use this in your activity tag in manifest file-
android:configChanges="orientation|keyboardHidden|screenSize"
please let me know if this does not work for you.
Solution 3:
Just store value using this method
publicvoidonSaveInstanceState(Bundle savedState) {
super.onSaveInstanceState(savedState);
// Note: getValues() is a method in your ArrayAdapter subclassString[] values = mAdapter.getValues();
savedState.putStringArray("myKey", values);
}
You can then retrieve the data in your onCreate method or onCreateView
or onActivityCreated
like this:
publicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
String[] values = savedInstanceState.getStringArray("myKey");
if (values != null) {
mAdapter = newMyAdapter(values);
}
}
...
}
Post a Comment for "How To Maintain Value Of Each Edittext In Customlistview"