Appcelerator - Android Picker无法响应点击/点击事件

时间:2017-10-16 05:04:37

标签: android titanium appcelerator

我正在尝试在我的视图中添加一个选择器,虽然选择器显示在屏幕上,但当点击它时,它不会显示我选择的选项。

这是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>

它只显示一个黑色矩形,显示第一行香蕉。

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

谢谢

更新

进一步测试显示这可能是由appcompat引起的。应用程序本身有一个自定义主题,在我从tiapp.xml删除了应用程序标记及其子项后,选择器正常工作。有人遇到过这个问题吗?

我的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 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>

更新2:

添加信息:

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

2 个答案:

答案 0 :(得分:0)

可能是因为useSpinner属性?它自5.2.1 SDK以来已弃用。

答案 1 :(得分:0)

问题来自主题之间的循环继承。您的自定义主题使用Theme.AppCompat.Translucent作为父级,但该主题本身被定义为您在tiapp.xml中提供的自定义主题的子级。这导致主题成为自己的孩子。我怀疑你没有收到错误,因为landingTheme充当Theme.AppCompat.Translucent的两个实例之间的一种代理。我建议您将landingTheme的父级设置为Theme.AppCompat,然后手动添加您要使用的Theme.AppCompat.Translucent的属性。