Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot control focus flow within compound views

Tags:

android

focus

Good evening (from Sweden)! I'm building a GUI based on a couple of Compound Views (an extended Layout containing one or more views) and i can't seem to get the focus flow in order. I primarily want to get the 'next' button on the keyboard working correctly. Currently pressing it does nothing except playing the click sound. I have tried:

android:nextFocusRight="@+id/ipDecimal"
android:nextFocusDown="@+id/ipDecimal"

And setting (both here and there)

android:focusable="true"

What am i doing wrong? My current goal is to get focus to flow from the first to the second IntegerPicker.

Here are the layouts for the 2 components i'm trying to work with at the moment (Both of them consists of an extended FrameLayout):

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:focusable="true" >

<com.SverkerSbrg.Spendo.Graphics.InsertTransaction.IntegerPicker
    android:id="@+id/ipInteger"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    custom:NumberSize="40"
    custom:TextAlignRight="true"
    android:focusable="true"
    custom:maxNrOfDigits="3"
    android:nextFocusRight="@+id/ipDecimal"
    android:nextFocusDown="@+id/ipDecimal">
    <requestFocus />
</com.SverkerSbrg.Spendo.Graphics.InsertTransaction.IntegerPicker>

<TextView
    android:id="@+id/tvDot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:text="."
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="30sp"
    tools:ignore="HardcodedText" />

<com.SverkerSbrg.Spendo.Graphics.InsertTransaction.IntegerPicker
    android:id="@+id/ipDecimal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:focusable="true"
    custom:NumberSize="20"
    custom:TextAlignRight="false"
    custom:maxNrOfDigits="2" >
</com.SverkerSbrg.Spendo.Graphics.InsertTransaction.IntegerPicker>

<TextView
    android:id="@+id/tvSpace"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"/>

<com.SverkerSbrg.Spendo.Graphics.InsertTransaction.CurrencyPicker
    android:id="@+id/icCurrency"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    custom:textSize="20"
    android:layout_gravity="bottom|center_horizontal">
</com.SverkerSbrg.Spendo.Graphics.InsertTransaction.CurrencyPicker>

</merge>

.

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
 >

<EditText
    android:id="@+id/etInteger"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:inputType="number"
    android:background="#00000000"
    android:selectAllOnFocus="true"
    android:focusable="true"
    android:hint="00">
</EditText>
</merge>
like image 338
SverkerSbrg Avatar asked Nov 29 '25 12:11

SverkerSbrg


1 Answers

After many hours frustrating of trying with different fixes, like invisible EditTexts which passes on focus to the right view.

If found that i could get the desired result buy catching the event from the next button on the keyboard.

this is done with a OnEditorActionListener.

like image 160
SverkerSbrg Avatar answered Dec 02 '25 05:12

SverkerSbrg