I have images displaying in Local HTML pages and have one button for click event. When click this button i need to call another activity. It's working. But the issue is after going another then come back to HTML pages the images are not displaying and app is not working.
<script language="javascript">
function validClick() {
valid.performClick();
document.getElementById("ok").value = "start";
}
function refuseClick(){
refuse.performClick();
document.getElementById("no").value = "Je refuse";
}
<div>
<button type="button" id="ok"
style="font-weight: 700; margin-right: 20px;" onclick="validClick();">Start</button>
</div>
HTML page contain image:
<li><a class="box" href="products.html" data-transition="fade" > <img src="img/products.png" alt="Products"> <span class="text"> Products</span>
MainActivity:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.about_screen);
WebView webview = (WebView) findViewById(R.id.webview);
webview.loadUrl("file:///android_asset/index.html");
valid = new Button(this);
valid.setOnClickListener(this);
refuse = new Button(this);
refuse.setOnClickListener(this);
// Enablejavascript
WebSettings ws = webview.getSettings();
ws.setJavaScriptEnabled(true);
// Add the interface to record javascript events
webview.addJavascriptInterface(valid, "valid");
webview.addJavascriptInterface(refuse, "refuse");
}
@Override
public void onClick(View v) {
if (v.equals(valid)) {
Intent i = new Intent(this, CloudReco.class);
startActivity(i);
} else if (v.equals(refuse)) {
//do Something else }
}