【发布时间】:2013-11-05 06:50:31
【问题描述】:
我在一个活动中有一个webView。在里面,webView 我有一个按钮,可以打开一个新的HTML 页面。当按下此按钮并打开新的 html 页面时,我希望屏幕方向更改为水平。
var searchButton = $('<button/>',
{
text:'Search!',
"class":"buttons",
id: "searchButtonID",
click: function(){
var select = document.getElementById("subCategory");
var option = select.options[select.selectedIndex];
var subCategoryId = option.id;
window.location.href = "deals.html?subCategoryId=" + subCategoryId;
Android.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
});
我最近了解到WebAppInterfaces 允许 Javascript 与 Android 交互。我尝试添加该行:
Android.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
但是,我收到一条错误消息:
Uncaught ReferenceError: ActivityInfo is not defined
我在相关类中导入了import android.content.pm.ActivityInfo;。
不确定我正在做的事情是否可能......
任何帮助将不胜感激!
【问题讨论】:
标签: javascript android webview screen-orientation