0

I have a list view and each row containing a TextView and EditText . while click in the EditText box soft key board gets open and i'm entering the value. After that while pressing back button to close the key board my list view gets refreshed and all the values entered in EditText also gone.

Please help me how to keep the values while key board gets closed?

if (ConvertViewP == null) {
            LayoutInflater inflater = (LayoutInflater) mContextL.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            ConvertViewP = inflater.inflate(R.layout.add_cart_row_layout, ParentP, false);
        }
4

2 回答 2

0

我建议你使用 SharedPreferences:

共享首选项

通过离开应用程序将值写入您的首选项,并在您启动/进入应用程序时将它们写回。

对我来说真的很好。

于 2013-03-13T13:32:56.233 回答
0

您可以将其全部保存在一个变量中。例如在你的有一些哈希图ListActivity

Map<Integer, String> mHashMap = new HashMap<Integer, String>();

其中键是列表项的位置,是输入到其中的文本,EditText要归功于在其上设置的侦听器。(在 EditText 中计数字符已更改侦听器)。并且ListAdapter.getView(int position, View convertView, ViewGroup parent)您将使用mHashMap并将按位置获取值(EditText如果有)。

如果您想在屏幕方向更改期间保留这些值,您可以轻松做到,因为Map可以Parcelable添加到Bundle使用 Save Instance State 保存 Android Activity 状态Bundle 中的 Android HashMap?

于 2013-03-14T13:54:25.560 回答