[Android] edittext focus in listview
Skyseraph Apr. 21st 2013
Email:Skyseraph00@163.com
I. Description:
Recently, a project needs to develop a table-like interface to display and configure parameters. Android does not directly support table-like controls. I used edittext and textview layout in listview, textview is used to display parameter specifiers, and edittext is used to display parameter values. A custom alertdialog dialog is displayed, as shown in.
Ii. Problems:
The developed APK software can be manipulated on mobile phones, but cannot be manipulated on TV, as shown in the following code:
Iii. solution:
1By setting the focus to stop on the listview, the problem that the listview cannot be clicked is solved. The method is as follows:
2For questions 2 and 3, they are mutually exclusive. For example, I manually set the focus to edittext. At this time, I cannot respond and click listview. Even worse, the logic is completely chaotic, for example, when I press the down key, the cursor stays in the first column, and the focus has been moved to the next column following the remote control. Press OK, the data in the row where the cursor stays is modified, as shown in figure 3. After repeated attempts, the following solutions can be solved.
Solution: In listview, set onitemselectedlistener's onitemselected and onnothingselected to enter the followingCode
3. Question 4The input method cannot be called up. The vast majority of input methods described on the Internet are useless. Only one method is OK. The original Article is linked here. The solution is as follows:
Iv. Description:
1For Android: descendantfocusability, there are three attribute values, which are described in the following table. For details, refer to the description in this blog.
Beforedescendants |
Viewgroup gets the focus with its subclass control given priority. |
Afterdescendants |
Viewgroup obtains focus only when its subclass controls do not need to obtain focus. |
Blocksdescendants |
Viewgroup overwrites the subclass control and directly obtains the focus. |