简体   繁体   English

在Android的listview中的webview,javascript算术运算不起作用

[英]webview inside the listview in Android, javascript arithmetic operations not working

I am working in webview. 我正在使用webview。 I have a toggle button in my web page and when I click that button it will call the javascript function. 我的网页上有一个切换按钮,当我单击该按钮时,它将调用javascript函数。
But it not properly working as expected. 但是它没有按预期正常工作。 When I call that function when it come to addition operation it stuck. 当我调用该函数进行加法运算时,它卡住了。 The only thing I done differently is I have webview inside listview. 我唯一做不同的事情是我在listview中有webview。

function fnTogglePositive(obj){  
    oTable = document.getElementById("tblData");  
    obj.innerHTML = "ALL";  
    var i = 0;  
        fnCheck(0,6);   
    }           
    else{                           
    obj.innerHTML = "POSITIVE";         
    }
}

function fnCheck(i,n){  
    var k = parseInt(i) + 1;  
    if(i<n){  
       document.getElementById("txt").value = k ;  
    }  
    else  
       return 0;  
}

I loaded this javascript function in webview inside the list view. 我在列表视图内的webview中加载了此javascript函数。 When I called the 当我打电话给
fnTogglePositive function it's not calculating the value, when the webview is inside the listview. 当webview在listview内部时,fnTogglePositive函数不计算值。

I created a separate activity which contains only the webview its working fine. 我创建了一个单独的活动,其中仅包含正常工作的webview。
I can able to figure out where it stuck. 我可以弄清楚它卡在哪里。 The function call happened but it stuck in calculating the 函数调用发生了,但是它在计算
value. 值。 Why it stuck in this point? 为什么它停留在这一点上?

Why this issue happened? 为什么发生此问题?

you need to build a bridge between you android code and JavaScript code. 您需要在android代码和JavaScript代码之间架起一座桥梁。
Check this guide 查看本指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM