Search code examples
androidfocusxamarin.androidandroid-tabactivitycustom-titlebar

EditText not getting focus Mono Android


I'm using TabActivity with Custom Title.

TabControl.xml contains

android:focusable="true"
android:focusableInTouchMode="true"

When activity gets launched, default tab is Tab0.

in .xml of Tab0:

android:focusable="true"
android:focusableInTouchMode="true"

while for custom title bar, TitleBar.xml contains:

<RelativeLayout
    //not setting android:focusable here >

    <EditText
            android:id="@+id/edsearch" 
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:nextFocusUp="@id/edsearch" 
            android:nextFocusLeft="@id/edsearch" >

But the problem is when I try to enter any input in EditText of TitleBar, it doesn't work. The reason behind this might be EditText is not having focus.

To rectify it, I used :nextFocusUp and :nextFocusUp as suggested In this discussion

But still it doesn't work.

I've used OnClick event for EditText which gets fired on click of it.

But TextChanged event is not getting executed as I'm not able to provide any input into EditText.

As I'm new to Mono Android, any help appreciated.


Solution

  • Remove

    android:focusable="true"    
    android:focusableInTouchMode="true"
    

    from the Tab activity.

    No need to set

    android:focusable="true"    
    android:focusableInTouchMode="true"    
    android:nextFocusUp="@id/edsearch"     
    android:nextFocusLeft="@id/edsearch"