Hi I'm trying to make an activity that displays an ExpandableListView as shown in the figure.
When you click on the group it expands and shows a LinearLayout with a textview and an editext.
Right know the problem I have is that when a click on the EditText it doesn't get focus and I have to tap twice on it in order to make it get focus and display the keyboard, and then when I enter text I see nothing initially while I'm typing and then when I hide the Keyboard the EditText is updated with the text I typed
I've tried adding android:descendantFocusability="afterDescendants" to the expandableListVie layout, but the behaviour is the same.
Any Idea?? or any other way I could implement this layout??
You have to add two things.
1)
expandableListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
2)In manifest(on your activity)
android:windowSoftInputMode="adjustPan"
I am not sure how to fix the focusing problem, but I know why you have to collapse and expand the group to see the text in the editText. The listview doesn't refresh unless you scroll or you do something like expanding and collapsing the listview. So the best way I can think of to fix this problem is to create a list of strings that will be the values of the editTexts in the listview. Then create a onKeyClick() listener for each of the editTexts and do this:
What happens here is that you are getting the value of the editText once a key has been pressed, and are changing the value of the string in the list to the new value. Then you are telling the adapter that the value of one of the items has changed an it needs to refresh. Although this is not an efficient way to fix the problem, it is a backup solution in case you can't think of a better way.
Try to store the values in the Edittext to a String variable using the function
and in the
getChild()
function always check for the data in temp andsettext()
value to that particularedittext
.add this to the manifest right after the android:name in your activity