为什么当我单击“后退”时,EditText 中的文本会消失...?

发布于 2024-12-09 14:43:57 字数 2195 浏览 0 评论 0原文

我有一个 ExpandableListView,其中正在加载具有 3 个编辑文本字段的自定义视图。

在这些编辑文本中输入值后,

我单击返回以最小化软键盘。

当时编辑框中的文本消失了,为什么..?

如果有人有任何想法请帮助我..?

这是我的 ExpandableListView 的 getGroupView 方法

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        System.out.println("Position = " + groupPosition);
        if (groupPosition == 0) {
            if (firstTime) {
                convertView = inflater.inflate(R.layout.pay_credit_card,
                        parent, false);
                checkBox1 = (Button) convertView.findViewById(R.id.check_box);
                email = (EditText) convertView.findViewById(R.id.email);
                phone1 = (EditText) convertView.findViewById(R.id.ph);
                phone2 = (EditText) convertView.findViewById(R.id.phone);
                checkBox1.setOnClickListener(headListener);
                firstTime = false;
            } else {
                emailSt = email.getText().toString();
                phone1St = phone1.getText().toString();
                phone2St = phone2.getText().toString();
                convertView = inflater.inflate(R.layout.pay_credit_card,
                        parent, false);
                checkBox1 = (Button) convertView.findViewById(R.id.check_box);
                email = (EditText) convertView.findViewById(R.id.email);
                phone1 = (EditText) convertView.findViewById(R.id.ph);
                phone2 = (EditText) convertView.findViewById(R.id.phone);
                checkBox1.setOnClickListener(headListener);
                email.setText(emailSt);
                phone1.setText(phone1St);
                phone2.setText(phone2St);
            }
            return convertView;
        } else {

            View v = null;
            v = inflater.inflate(R.layout.pay_group_head, parent, false);
            String gt = (String) getGroup(groupPosition);
            TextView tv2 = (TextView) v.findViewById(R.id.tvGroup);
            if (gt != null && tv2 != null)
                tv2.setText(gt);
            return v;
        }
    }

提前致谢...!

I have a ExpandableListView in which i am loading my custom views having 3 edit text fields.

After entering the values into those edit texts,

i am clicking back to minimize the soft keyboard.

That time the text in the edit boxes is disappearing Why..?

If anybody have any idea please help me..?

This is my getGroupView method of ExpandableListView

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        System.out.println("Position = " + groupPosition);
        if (groupPosition == 0) {
            if (firstTime) {
                convertView = inflater.inflate(R.layout.pay_credit_card,
                        parent, false);
                checkBox1 = (Button) convertView.findViewById(R.id.check_box);
                email = (EditText) convertView.findViewById(R.id.email);
                phone1 = (EditText) convertView.findViewById(R.id.ph);
                phone2 = (EditText) convertView.findViewById(R.id.phone);
                checkBox1.setOnClickListener(headListener);
                firstTime = false;
            } else {
                emailSt = email.getText().toString();
                phone1St = phone1.getText().toString();
                phone2St = phone2.getText().toString();
                convertView = inflater.inflate(R.layout.pay_credit_card,
                        parent, false);
                checkBox1 = (Button) convertView.findViewById(R.id.check_box);
                email = (EditText) convertView.findViewById(R.id.email);
                phone1 = (EditText) convertView.findViewById(R.id.ph);
                phone2 = (EditText) convertView.findViewById(R.id.phone);
                checkBox1.setOnClickListener(headListener);
                email.setText(emailSt);
                phone1.setText(phone1St);
                phone2.setText(phone2St);
            }
            return convertView;
        } else {

            View v = null;
            v = inflater.inflate(R.layout.pay_group_head, parent, false);
            String gt = (String) getGroup(groupPosition);
            TextView tv2 = (TextView) v.findViewById(R.id.tvGroup);
            if (gt != null && tv2 != null)
                tv2.setText(gt);
            return v;
        }
    }

Thanks in advance...!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你好,陌生人 2024-12-16 14:43:57

正如已经发布的评论:

为了解决文本输入消失的问题,您需要将文本输入直接保存到某种字符串数组或类似的数组中,这允许 ListView 在重新加载表时检索数据

很高兴我可以提供帮助

As already posted as comment:

In order to solve the problem of vanishing textinput, you need to save the textinput directly to some kind of string-array or similar which allows the ListView to retreive the data when it reloads the table

Glad I could help

执笏见 2024-12-16 14:43:57

尝试删除字典选项并查看。
如果您想保存编辑文本中的内容,则必须使用共享首选项或其他类似的保存选项。

Try removing the dictionary option and see.
and if you want to save the contents in the edit text then you have to use shared preference or other similar saving options.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文