Focus definition

23 views
Skip to first unread message

Csaba Troják

unread,
Sep 16, 2013, 12:25:10 PM9/16/13
to android...@googlegroups.com
I have a collection of viewmodels in an ArrayObservable, let's assume VM1 and VM2 is in it.

Each VM defines a LayoutID, VM1 defines 'layoutOneText' and VM2 defines 'layoutTwoText'

This ArrayObservable is displayed (bound by) a BindableLinearLayout.

VM1's layout (layoutOneText) displays one EditText (ED0) centered horizontally

VM2's layout (layoutTwoText) displays two EditTexts next to each other (ED1 and ED2) centered horizontally.

When the page is rendered, the following UI is displayed (more or less):

    ED0
ED1 ED2

The problem is that when ED0 get's focus, and the user clicks 'Next' on the keyboard, ED2 is focused, and not ED1.

I must have ED1 focused in my case.

How can I do this, because layouts know nothing about each other (they shouldn't know), and it can happen that even more VMs are in the list, producing the following UI:

    ED0
ED1 ED2
    ED0
ED1 ED2
ED1 ED2

I want the focus to be: ED0 -> ED1 -> ED2 -> ED0(3rd row) -> ED1 (4th) -> ED2 (4th) -> and so on...

Of course I could define the focus-navigation-direction ISIDE 'layoutTwoText', so focus between ED1 and ED2 is OK, the problem comes between layouts.

Bye,
Csabi

Csaba Troják

unread,
Dec 5, 2013, 3:29:12 PM12/5/13
to android...@googlegroups.com
Andy, could you give advice on my issue above?

Andy Tsui

unread,
Dec 6, 2013, 7:59:47 PM12/6/13
to android...@googlegroups.com
Hi,

Sorry for the long wait.. I think I over-read this message before. 

How large is your ArrayListObservable (those VM1s and 2s)? I would first suggest you to use ListView rathr than LinearLayout (or the BindableLinearLayout) to display those items. This is because LinearLayout is more or less designed to handle more definite amount on items and every layout is created/loaded per item, performance is not good for longer lists. 

Please try to replace the LinearLayout first, and then see if the problem still there. If yes, then post your XMLs (of both VM1/2's View). 

Andy
Reply all
Reply to author
Forward
0 new messages