import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
final WebView mWebView = (WebView) findViewById(R.id.webView);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
String url = "https://www.webnotes.cz/";
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(url);
mWebView.setWebViewClient (new WebViewClient() {
public void onPageFinished(WebView view, String url) {
String user="u";
String pwd="p";
view.loadUrl("javascript:document.getElementById('UID0').value = '"+user+"';document.getElementById('PASS0').value='"+pwd+"';");
}
});
}
}
感谢您的回复!
答案 0 :(得分:1)
在将视图扩展为活动之后,应该初始化视图,这是使用setContentView()完成的。在setContentView();
之后将下面的行移到onCreate()方法mWebView = (WebView) findViewById(R.id.webView);
答案 1 :(得分:1)
注意: - 仅在onCreate方法中初始化webview或任何其他视图...因为findviewById在设置内容视图(布局)之前不会获得该视图的ID
var d = new Date('2016/10/29 17:00');
console.log(d.toLocaleDateString('se').replace(/\D/g, ''));