Focus issue in ListView EditText display in Dialog in Android
I have to display ListView contains EditText on Dialog, where a user can type the text in EditText and its content should not be lost.
For example, I have 10 EditText in listview, if the user types "11" in first EditText , "22" in second EditText , "33" in third EditText and scroll down the listview at tenth EditText after that user scroll it up again at first EditText at that time the value in first EditText should be "11", for second EditText "22" and so on, I have achieved this by setting EditText when text gets changed in EditText.
I use NiftyDialog as dialog (Link). The issue is that the EditText got focus randomly (it sometimes worked and sometimes not).
I have set
android:descendantFocusability="afterDescendants"
in ListView and set
android:windowSoftInputMode="adjustPan"
in Manifest File, but its not working properly.
What can be the issue here?
使用大小为10的字符串类型的另一个列表,并将每个字符串的最初位置置于空白处,然后在edittext和onTextchange方法上添加一个textwatcher重新指定该特定位置的列表中的字符串值。请提供您的适配器代码
Are you explicitly requesting focus for the EditText? As in myEditText.requestFocus()
From your question, it seems you want the focused edit text to change as the user scrolls down. Can you clarify the behavior you expect and what is occuring?
I had this issue a while ago with EditText
focus and realized that just setting the attributes on existing views wont work. In my case it was to avoid the keypad from poping up, but I believe, the same solution will work in your case too.
Add a dummy layout with android:focusable="true"
and android:focusableInTouchMode="true"
on top above all other views. This way the focus would go to this layout (which is at the top) and your random focus problem with the EditText
in the ListView
will get resolved.
<!-- Stop auto focussing the EditText -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true">
</LinearLayout>
链接地址: http://www.djcxy.com/p/24240.html