Search code examples
androidtitaniumappcelerator

Appcelerator - Android Picker not responding to tap/click event


I'm trying to add a picker to my view and although the picker displayed on the screen, when tap on it it doesn't show the option for me to choose from.

This is the xml:

<Window class="container" platform="android" backgroundColor="white">
        <Picker id="picker" backgroundColor="black" selectionIndicator="true" useSpinner="false">
            <PickerColumn id="column1">
                <PickerRow title="Bananas"/>
                <PickerRow title="Strawberries"/>
                <PickerRow title="Mangos"/>
                <PickerRow title="Grapes"/>
            </PickerColumn>
        </Picker>
    </Window>

It just show a black rectangle with the first row Bananas displayed.

Appcelerator info: 
Node version: 6.9.5 
Titanium SDK: 6.1.1.GA
Target OS : Android

Thank you

UPDATE:

Further test reveal that this could be caused by appcompat. The app itself has a custom theme and after i removed the application tag and its children from the tiapp.xml the picker worked normally. Anyone encountered this issue?

My custom_theme.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.SplashScreen" parent="@style/Theme.AppCompat.Fullscreen">
        <item name="android:windowBackground">@drawable/background</item>
        <item name="android:windowActionBar">false</item>       
        <item name="android:windowNoTitle">true</item>
    </style>

    <style name="landingTheme" parent="@style/Theme.AppCompat.Translucent">
        <item name="android:windowBackground">@color/transparent</item>

        <item name="colorPrimary">@color/primaryColor</item>

        <item name="android:editTextStyle">@style/Widget.EditText</item>
        <item name="android:drawSelectorOnTop">true</item>
    </style>

    <!-- <style name="Theme.TranslucentNoActionBar" parent="@style/Theme.AppCompat.Translucent"> -->
    <style name="Theme.TranslucentNoActionBar" parent="@style/Theme.AppCompat.Translucent.NoTitleBar">
        <!-- Depending on the parent theme, this may be called android:windowActionBar instead of windowActionBar -->
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@color/transparent</item>

        <item name="colorPrimary">@color/primaryColor</item>

        <item name="android:editTextStyle">@style/Widget.EditText</item>
        <!--item name="android:buttonStyle">@style/Widget.App.Button</item-->
    </style>

    <style name="Widget.EditText" parent="Widget.AppCompat.EditText">
        <item name="android:padding">0dp</item>
        <item name="android:background">@color/transparent</item>
        <item name="android:includeFontPadding">false</item> 
    </style>

</resources> 

application tag that was removed:

<application android:theme="@style/landingTheme">
                <activity
                    android:configChanges="keyboardHidden|orientation|screenSize"
                    android:label="@string/app_name"
                    android:name=".myActivity"
                    android:theme="@style/Theme.SplashScreen" android:windowSoftInputMode="stateHidden|adjustResize">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
                <!-- Prevent android from auto focus textfield - https://developer.appcelerator.com/question/120852/keyboard-launch-automatically-without-focus-textfield -->
                <activity
                    android:configChanges="keyboardHidden|orientation|screenSize"
                    android:name="org.appcelerator.titanium.TiTranslucentActivity"
                    android:theme="@style/Theme.TranslucentNoActionBar" android:windowSoftInputMode="stateHidden|adjustResize"/>
                <activity
                    android:configChanges="keyboardHidden|orientation"
                    android:name="org.appcelerator.titanium.TiActivity"
                    android:theme="@style/Theme.TranslucentNoActionBar"
                    android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden|adjustResize"/>
            </application>

UPDATE 2:

Adding info:

Test Device: Huawei P9 
Device Android OS: 7.0 
Targetted Android version: API 23

Solution

  • The problem comes from a circular inheritance between the themes. Your custom theme uses Theme.AppCompat.Translucent as a parent, but that theme itself is defined to be a child of the custom theme you provide in tiapp.xml. And that leads to a theme being a child of itself. I suspect you do not get an error because landingTheme acts as a kind of proxy between the two instances of Theme.AppCompat.Translucent. I would suggest that you set the parent of landingTheme to be Theme.AppCompat and manually add the properties of Theme.AppCompat.Translucent that you want to use.