2017-09-24 1 views

답변

0

예 당신이 할 수있는 내가 프로그램에 주어진 그 값으로로드되는 웹보기를 필요 안드로이드 웹뷰

나는이 코드를 시도했지만 그것은

final String sectionName = getIntent().getStringExtra("sectionName"); 
     final String consumerNumber = getIntent().getStringExtra("consumerNumber"); 
     final String billNumber = getIntent().getStringExtra("billNumber"); 
     this.web = (WebView) findViewById(R.id.web); 
     this.web.loadUrl(Constants.Payment_URL); 
     this.web.getSettings().setJavaScriptEnabled(true); 
     this.web.setWebViewClient(new WebViewClient() { 
      public void onPageFinished(WebView view, String url) { 
       Log.e("TAG", "sectionName:" + sectionName); 
      view.loadUrl("javascript:$($(\"#sectionCode option\")[" + sectionName + "]).prop('selected','selected');$('#ConsumerNo').val('" + consumerNumber + "');$('#billNo').val('" + billNumber + "');"); 
       } 

      public void onPageStarted(WebView view, String url, Bitmap favicon) { 
       super.onPageStarted(view, url, favicon); 
       } 
     }); 

를 작동하지 않는 그 자바 스크립트의 도움으로 .

여러 가지 방법으로 자바 스크립트를 웹보기에 삽입 할 수 있습니다.

JavaScript 인젝터 라이브러리를 사용하는 것이 좋습니다. 여기에서 찾을 수 있습니다.

https://github.com/henrychuangtw/WebView-Javascript-Inject

관련 문제