0
Utilise WebView
, open the site normally, but need that when accessing, it pass a value of a given field of the site to a TextView
.
It is possible to do this ?
Follow the code below:
public class Inicio extends AppCompatActivity {
TextView recuperarvalor;
WebView site;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inicio);
recuperarvalor = (TextView) findViewById(R.id.idtextview);
site = (WebView) findViewById(R.id.idwebview);
site.loadUrl("https://nomedosite");
WebSettings settings = site.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.supportZoom();
settings.setBuiltInZoomControls(true);
settings.setTextZoom(150);
settings.setSupportZoom(true);
settings.setDomStorageEnabled(true);
site.loadUrl("javascript:var x = document.getElementById('live_bid');");
site.setWebViewClient(new WebViewClient() {
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
site.loadUrl("javascript:var x = document.getElementById('live_bid');");
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
}
}
hello! how do you open the site? Can show the code? it gets easier to help!
– Thiago Luiz Domacoski
I updated with the code above.
– Diego Kappaun