0

I am currently using an ExpandableListView with a EditText as a child item. I want to give focus to the EditText when the item is expanded and automatically display the keyboard.(This turned out to be more difficult than what I expected. I can give focus to the EditText(using this post Focusable EditText inside ListView), but the keyboard is either never shown or it blinks and then hides itself).

Is a ListView the best approach to do this? Should I rather be looking at creating dynamic views inside a LinearLayout of a ScrollView?

Any suggestions/Ideas?

Community
  • 1
  • 1
Jacques
  • 747
  • 1
  • 8
  • 19
  • Look at http://en.wikicode.org/index.php/Custom_ExpandableListView and http://www.techienjoy.com/android-expandable-list-dynamically-created-example.php u will get Hint – Ronak Mehta Feb 29 '12 at 06:35
  • Thanks Rstar, I will try it and let you know. – Jacques Feb 29 '12 at 15:38

1 Answers1

0

Sounds like some other view other than your TextView is receiving focus after your TextView receives focus. I would debug by overriding onFocus events on some Views and seeing if they get hit after your TextView.

Catalina
  • 1,954
  • 1
  • 17
  • 25
C Nick
  • 2,500
  • 2
  • 17
  • 21
  • Hi Nick, I am busy doing that right now. The problem is that the create view is called a million times during the ExpandableListView's lifetime, and I am sure when all is said and done, the ExpandableListView gets back the focus. This leaves me with the question......why is the keyboard not shown for a textbox with focus? And On which event can I manually call the SoftInput? – Jacques Mar 01 '12 at 08:31
  • I've ran into a situation where my Textbox has focus, but doesn't bring up the keyboard. From what I remember when I debugged source, the TextView widget has logic in it that expects a down/up touch event sequence, and on the up will call the InputMethodManager to show the keyboad. I had a problem where the up event would fire (still don't know why). It sounds like you have an event to expand your row, so at the end of that you can try to manually invoke the keyboard. Also on the ListView there is a setItemsCanFocus() method, make sure that is true. – C Nick Mar 02 '12 at 14:32