为什么当我单击“后退”时,EditText 中的文本会消失...?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如已经发布的评论:
为了解决文本输入消失的问题,您需要将文本输入直接保存到某种字符串数组或类似的数组中,这允许 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
尝试删除字典选项并查看。
如果您想保存编辑文本中的内容,则必须使用共享首选项或其他类似的保存选项。
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.