Android HTML5游戏[关闭](Android HTML5 Games [closed])
我尝试从互联网加载HTML5游戏并在我的WebView中显示它但是当我尝试这样做时我无法加载游戏,我的显示器是黑色的,我的屏幕上只有一条线(大约30px高)是我的代码
public class BrowserGame extends MenuHandler { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.browsergame); WebView browser = (WebView)findViewById(R.id.webGame); browser.setFocusableInTouchMode(false); browser.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); Bundle game = getIntent().getExtras(); String gameURL = game.getString("gameURL"); browser.loadUrl(gameURL); } }
当我在移动浏览器上尝试相同的链接时,它会显示游戏。
谢谢。
I try to load HTML5 game from internet and show it in my WebView but when I try to do that I can't load the game, my monitor is black and there is only one line (about 30px high) that is on my screen this is my code
public class BrowserGame extends MenuHandler { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.browsergame); WebView browser = (WebView)findViewById(R.id.webGame); browser.setFocusableInTouchMode(false); browser.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); Bundle game = getIntent().getExtras(); String gameURL = game.getString("gameURL"); browser.loadUrl(gameURL); } }
When I try same link on mobile browser it shows the game.
Thanks.
原文:https://stackoverflow.com/questions/7152705
最满意答案
在这里,您可以使用解决方案https://jsfiddle.net/vh1bmfuz/
var item = { Category: 1, Description: 'Description 1.1', 'Description 2': 'Description 1.2', status: 'Status 1', 'Group 1': 'group1.1', 'Group 2': 'group1.2', 'A': 1, 'B': 2} var matchMethod = function(){ return ((item['A'] != item['B']) ? 'Great' : 'Ops'); } var tr = `<tr> <td>${item['Group 1']}</td> <td>${item['Group 2']}</td> <td>${item['Description']}</td> <td>${item['Description 2']}</td> <td>${matchMethod()}</td> </tr>`; $('table').append(tr);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table></table>
我有一种方法可以根据匹配的条件检查并返回一个字符串。
希望这会帮助你。
Here you go with a solution https://jsfiddle.net/vh1bmfuz/
var item = { Category: 1, Description: 'Description 1.1', 'Description 2': 'Description 1.2', status: 'Status 1', 'Group 1': 'group1.1', 'Group 2': 'group1.2', 'A': 1, 'B': 2} var matchMethod = function(){ return ((item['A'] != item['B']) ? 'Great' : 'Ops'); } var tr = `<tr> <td>${item['Group 1']}</td> <td>${item['Group 2']}</td> <td>${item['Description']}</td> <td>${item['Description 2']}</td> <td>${matchMethod()}</td> </tr>`; $('table').append(tr);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table></table>
I've a method that will check & return a string based on condition matched.
Hope this will help you.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
问题是您在第二次调用该函数时不清除该数组。 你每次都需要清除它。 你可以创造一个新的功能Countcoin(n) function Countcoin(n){ co = []; coin(n) } 现在称这个函数而不是coin 或者你可以只构建一个函数,但使用循环,而不是递归。 var co = []; function coin(n){ co=[]; while(n!=0){ if (n>=25){ co.push("25"); ...
-
有多种方法可以做到这一点 ,所有这些都是“正确的”和有效的方法来做你想做的事情。 这真的归结为你的代码风格以及对你来说可读/有意义的东西......我将添加一些不同的方法来做到这一点,这样你就可以看到我的意思并决定什么最适合你:) jsx中的条件的三元运算符{ error ?如果使用逻辑&& (也就是short-circuit evaluati ...
Sorry - there was an error
:{this.state.data}
} -
没有JavaScript的简单解决方案看起来像这样(把它放在你的 ): 这会将用户重定向到http://example.com/ie.html (只需用实际网址替换该部分)。 此解决方案的优点:如果用户已停用JavaScript ,它也可以工作。 The simple solution, w ...
-
如何在JavaScript函数中的html中插入条件语句?(How to insert conditional statements in html inside a JavaScript function?)[2023-07-27]
在这里,您可以使用解决方案https://jsfiddle.net/vh1bmfuz/ var item = { Category: 1, Description: 'Description 1.1', 'Description 2': 'Description 1.2', status: 'Status 1', 'Group 1': 'group1.1', 'Group 2': 'group1.2', 'A': 1, 'B': 2} var matchMethod = function(){ ... -
有不止一种方法可以做到这一点。 首先 ,您可以使用.innerHTML编辑任何元素的内容,但要注意这是破坏性的 - 它会删除旧内容并添加新内容,即使您使用innerHTML += '' 。 在你的情况下这可能是坏事,因为如果内容包含iframe它可能会再次加载它,如果任何属性/事件已被添加到容器内的任何元素,它们将被销毁。 例: var el = document.getElementById('google_ads_div_TEST_960x300_ad_container'); el.innerHTML ...
-
创建元素p ,您必须将其附加到文档中的某个位置。 但首先,我将创建元素并将它们附加到p,而不是innerHTML,如下所示: var p = document.createElement("div"); p.appendChild( document.createTextNode("Script to calculate the eligibility of a u20 player ") ); var el = document.createElement("div"); el. ...
-
我想你想要一个换行符,而不是休息。 alert(element+"\n"+prop="="+star[element][prop]); 其中\n在元素和prop =部分之间添加换行符。 I think you want to put a newline character, not a break. alert(element+"\n"+prop="="+star[element][prop]); Where \n puts a newline between the element and the p ...
-
如何在Rails视图中调用条件内的javascript函数?(How to call a javascript function inside a conditional in Rails view?)[2023-06-21]
我觉得你弄错了。 Javascript在客户端呈现,而rails部分在服务器端呈现。 当服务器尝试呈现“if”语句时,它对javascript函数一无所知。 I think you got it wrong. Javascript is rendered on the client side, while the rails part is rendered on the server side. When the server tries to render your 'if' statement it ... -
你必须稍微重写你的验证码。 检查演示 - 演示 : 你的问题: 函数在检查gender之前返回; 你不能通过这种方式检查多个复选框: if(gender.checked) 以下是工作代码 function validate_form() { var name = document.getElementById("id1").value, gender = document.getElementsByName("gender"), res ...