Android EditText in ListView - keyboard(ListView 中的 Android EditText - 键盘)
问题描述
我的 EditText
有问题.我使用以下适配器:
I've got a problem with my EditText
. I use the following adapter:
public class RowTextViewAdapter extends BaseAdapter {
...
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (rowTitles.get(position).equals("edit")) {
if(et == null){
et = new EditText(activity);
et.setText("Test");
}
return et;
}
else {
convertView = new TextRow(activity);
holder = new ViewHolder(((TextRow) convertView).getTextView(), ((TextRow) convertView).getImageView());
convertView.setTag(holder);
holder.getTextView().setText(StringManager.getInstance().getText(rowTitles.get(position), activity));
holder.getImageView().setImageBitmap(assetController.getBitmap(additiveIcons.get(position) + ".png", null));
return convertView;
}
}
}
和ListActivity
:
public class AppSettingActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adapter = new RowTextViewAdapter(this);
adapter.addRowView("account", "arrowDw");
adapter.addRowView("password", "arrowDw");
setListAdapter(adapter);
}
...
protected void onListItemClick(ListView listView, View view, int position, long id) {
switch (position) {
case 0: accIsEditable = adapter.setEditable(position); break;
case 1:
if(accIsEditable) {
//TODO do something..
break;
}
pwIsEditable = adapter.setEditable(position);
break;
...
}
}
如果我单击第一项,我会在 pos 上添加一个新的列表项.1(位置:0、1、2、...).现在 EditText
字段已添加到列表中.
If i click on the first item I add a new list item on pos. 1 (pos: 0, 1, 2, ...).
Now the EditText
field is added to the list.
ListView:
---------------------------- -------------------------
Account v Account ^
---------------------------- ==> -------------------------
Passowrd v [::::::::EditText:::::::]
---------------------------- -------------------------
//more.. Password v
---------------------------- -------------------------
//more..
-------------------------
如果我现在单击 EditText
字段,它会显示虚拟键盘并失去 EditText
的焦点.我再次单击它并获得焦点.但是如果我写东西,文本只会显示在 EditText
字段中,如果我在写的时候不经常点击它...
If I click now into the EditText
field, it shows the virtual keyboard and loses focus of the EditText
. I click again and it gains focus. But if I write something, the text is only showed in the EditText
field, if i tap on it and not frequently while i'm writing...
有解决这个更新问题的想法吗?
Any idea to fix that update problem?
推荐答案
如果这仍然是一个问题,请查看此项目:ListView内可聚焦的EditText
If this is still an issue, take a look at this item: Focusable EditText inside ListView
这些更改可能会有所帮助.
This changes may help.
更改为列表视图:
<ListView
android:id="@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:descendantFocusability="beforeDescendants"
/>
更改为 mainfest.xml 中的活动:
Change to activity in mainfest.xml:
<activity android:name= ".yourActivity" android:windowSoftInputMode="adjustPan"/>
这篇关于ListView 中的 Android EditText - 键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ListView 中的 Android EditText - 键盘
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01