Ich habe durch viele Post und Foren gegangen, konnte aber keine Lösung finden. Ich entwickle eine Anwendung mit lokalen HTML-Dateien in, für die habe ich diese HaupttätigkeitVariable Ansicht möglicherweise nicht initialisiert und Variablenansicht von Innenansicht
package com.faraksoch.sagar.eroutine;
public class MainActivity extends AppCompatActivity {
boolean doubleBackToExitPressed = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setAllowFileAccess(true);
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
findViewById(R.id.image1).setVisibility((View.GONE));
findViewById(webView).setVisibility(View.VISIBLE);
}
});
webView.loadUrl("file:///android_asset/index.html");
webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Intent intent = new Intent(MainActivity.this, UpdateService.class);
startService(intent);
}
boolean doubleBackToExitPressedOnce = false;
@Override
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
return;
}
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this, "Please click BACK again to exit",
Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
}, 2000);
}
WebView webView;
public void goBack(){
if (webView.canGoBack()) {
webView.goBack();
} else {
finish();
}
}
}
Hier in Zeile
WebView webView = (WebView) findViewById(webView);
Ich bin Fehler von webView bekommen könnte nicht initialisiert worden und in Zeile
Variable WebView wird von Innter Klasse Whi zugegriffen ch muss endgültig erklärt werden und so, wenn ich Code zu diesem
final WebView webView = (WebView) findViewById(webView);
immer noch kein Glück zu ändern.
und meine Main_activity Datei ist
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.faraksoch.sagar.eroutine.MainActivity">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="368dp"
android:layout_height="576dp"
android:background="@drawable/ssplash" />
</android.support.constraint.ConstraintLayout>
jemand mir dabei helfen kann, was muss ich es funktioniert zu tun.
Wie soll ich es endgültig machen. Wo sollte ich welchen Code setzen, um es dann endgültig zu machen? –