gpt4 book ai didi

android - 在 Titanium/Alloy/Appcelerator 上隐藏 Android 上的操作栏

转载 作者:太空狗 更新时间:2023-10-29 15:50:38 24 4
gpt4 key购买 nike

如何在 Alloy/Titanium 上隐藏 Android 上的操作栏。我尝试了以下方法:

$.index.activity.actionBar.hide()

但它只是抛出错误:

 Cannot read property 'hide' of undefined

完整错误信息如下:

[ERROR] :  TiExceptionHandler: (main) [1605,1605] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,1605] - In /alloy/controllers/index.js:359,27
[ERROR] : TiExceptionHandler: (main) [1,1606] - Message: Uncaught TypeError: Cannot read property 'hide' of undefined
[ERROR] : TiExceptionHandler: (main) [0,1606] - Source: win.activity.actionBar.hide();
[ERROR] : V8Exception: Exception occurred at /alloy/controllers/index.js:359: Uncaught TypeError: Cannot read property 'hide' of undefined

最佳答案

您需要注意以下几点:

问题 1 - 你想隐藏所有窗口的操作栏(意味着整个应用程序)吗?

问题 2 - 您是否希望在打开窗口并执行某些操作(即单击或滚动)后隐藏操作栏?

问题 3 - 是否要为少数窗口隐藏 Action Bar 而为其他窗口显示它?


答案 1:- 使用内置的 Titanium 主题

方法 1 - 在 tiapp.xml 文件中使用此标记:

<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.AppCompat.NoTitleBar"/>
</manifest>
</android>

方法 2 - 在 app.tss 中设置 theme 属性:

"Window[platform=android]":{
theme : 'Theme.AppCompat.NoTitleBar'
}


答案2:

您遇到的问题就是这种情况。只有在窗口打开时才能通过 .js 文件中的代码隐藏操作栏。您将必须使用 window 的 onOpen 事件来运行此代码:

$.index.activity.actionBar.hide();

所以,它一定是这样的:

$.index.addEventListener('open', function () {
$.index.activity.actionBar.hide();
});

或者您可以在某些按钮单击时运行 hide() 方法,因为当显然该窗口打开时您将能够单击按钮,如下所示:

$.someButton.addEventListener('click', function () {
$.index.activity.actionBar.hide();
});


答案 3:

通过使用答案1方法2,您可以在.tss或.xml文件中应用主题来隐藏相应窗口的操作栏并且不要在将具有操作栏的窗口上应用任何主题。


在此处阅读更多关于 Titanium Android Themes 的信息

关于android - 在 Titanium/Alloy/Appcelerator 上隐藏 Android 上的操作栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42843639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com