Yah*_*din 2 android titanium appcelerator titanium-alloy appcelerator-titanium
如何在Alloy/Titanium上隐藏Android上的操作栏.我尝试过以下方法:
$.index.activity.actionBar.hide()
Run Code Online (Sandbox Code Playgroud)
但它只是抛出错误:
Cannot read property 'hide' of undefined
Run Code Online (Sandbox Code Playgroud)
完整的错误消息如下:
[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
Run Code Online (Sandbox Code Playgroud)
您需要注意的事情很少:
问题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>
Run Code Online (Sandbox Code Playgroud)
方法2 - 在app.tss中设置主题属性:
"Window[platform=android]":{
theme : 'Theme.AppCompat.NoTitleBar'
}
Run Code Online (Sandbox Code Playgroud)
这是你遇到这个问题的情况.只有在打开窗口时,才能通过.js文件中的代码隐藏操作栏.您将不得不使用window的onOpen事件来运行此代码:
$.index.activity.actionBar.hide();
Run Code Online (Sandbox Code Playgroud)
所以,它必须是这样的:
$.index.addEventListener('open', function () {
$.index.activity.actionBar.hide();
});
Run Code Online (Sandbox Code Playgroud)
或者你可以在某个按钮点击上运行hide()方法,因为当显然打开窗口时你可以点击一个按钮,如下所示:
$.someButton.addEventListener('click', function () {
$.index.activity.actionBar.hide();
});
Run Code Online (Sandbox Code Playgroud)
通过使用方法2的回答1,你可以在应用主题.tss或.xml文件隐藏在各自的窗口操作栏上,不得将有所动作栏windows应用任何主题.
在Titanium Android主题上阅读更多内容
| 归档时间: |
|
| 查看次数: |
1279 次 |
| 最近记录: |