0
我在我的活動中插入了webview,但插入的webview的導航抽屜工作不正常(每當我點擊它時,它都會一直加載)。其他一切工作正常。無法打開插入的webview的導航抽屜
This is the image which i am talking about
下面給出的是在我所插入的WebView的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_education"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_overlay"
android:orientation="vertical"
tools:context="com.aaryanapps.mdconnect.ui.activity.EducationActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<include layout="@layout/dashboard_actionbar" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/my_awesome_toolbar">
<WebView
android:id="@+id/education_webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white" />
</RelativeLayout>
</LinearLayout>
<include layout="@layout/navigation_drawer_view" />
</android.support.v4.widget.DrawerLayout>
下面給出的是Java代碼加入web視圖:
package com.aaryanapps.mdconnect.ui.activity;
import android.os.Bundle;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.aaryanapps.mdconnect.R;
public class EducationActivity extends NavigationActivity {
private WebView _webview;
private boolean _webview_loaded = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
mToolbarTitleText = "Education";
super.onCreate(savedInstanceState);
_webview = (WebView) findViewById(R.id.education_webView);
_webview.setWebViewClient(new WebViewClient());
if (!_webview_loaded) {
updateViews();
}
}
protected void prepareInit() {
content_view = R.layout.activity_education;
}
private void updateViews() {
if (null == _webview || _webview_loaded) {
return;
}
_webview_loaded = true;
String desc = "http://www.google.com";
//General.replaceNull(cad.getlong_description());
if (URLUtil.isHttpUrl(desc) || URLUtil.isHttpsUrl(desc)) {
//Load the url in the webview.
_webview.loadUrl(desc);
return;
}
_webview.getSettings().setJavaScriptEnabled(true);
_webview.loadData(desc,"text/html", "UTF-8");
}
}
請問您能更具體些嗎? @vryin和耶,「試着把它放在另一個佈局中」,我們必須創建另一個佈局資源文件或者只是將Linearlayout更改爲RelativeLayout? – Msavaj
我的意思是「試着把它放在另一個佈局中」意味着它是你自己的代碼,你沒有注意到相似之處嗎?是的,你必須創建另一個佈局資源文件,因爲它似乎彼此有衝突。 – Bryan
無法使用@vryin – Msavaj