問題描述
我的 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、...).現(xiàn)在 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..
-------------------------
如果我現(xiàn)在單擊 EditText
字段,它會顯示虛擬鍵盤并失去 EditText
的焦點.我再次單擊它并獲得焦點.但是如果我寫東西,文本只會顯示在 EditText
字段中,如果我在寫的時候不經(jīng)常點擊它...
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內(nèi)可聚焦的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 - 鍵盤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!