d
This commit is contained in:
@@ -120,6 +120,12 @@ public class Main4Fragment extends BaseFragment<FragmentMain4Binding> implements
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
mDataBinding.ll5.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebActivitytwo.runActivity(getActivity(), "", "https://wy.dou1.net/articlemobile/index/detail?article_id=19");
|
||||
}
|
||||
});
|
||||
//mDataBinding.myRecyView;
|
||||
mDataBinding.userImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
105
app/src/main/java/com/sl/house_property/WebActivitytwo.java
Normal file
105
app/src/main/java/com/sl/house_property/WebActivitytwo.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.sl.house_property;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class WebActivitytwo extends AppCompatActivity implements View.OnClickListener {
|
||||
public final static String URL = "url";
|
||||
public final static String TITLE = "title";
|
||||
private WebView webView;
|
||||
private ProgressBar pb;
|
||||
private RelativeLayout mLayTopLeftTv;
|
||||
private TextView mLayTopTitle;
|
||||
private TextView mRight;
|
||||
private ImageView mIvCode;
|
||||
private ProgressBar mPb;
|
||||
private WebView mWebView;
|
||||
|
||||
public static void runActivity(Context context, String title, String url) {
|
||||
Intent intent = new Intent(context, WebActivitytwo.class);
|
||||
intent.putExtra(URL, url);
|
||||
intent.putExtra(TITLE, title);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_webtwo);
|
||||
String url = getIntent().getStringExtra(URL);
|
||||
String title = getIntent().getStringExtra(TITLE);
|
||||
|
||||
initView();
|
||||
pb.setMax(100);
|
||||
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setDomStorageEnabled(true);//主要是这句
|
||||
webSettings.setJavaScriptEnabled(true);//启用js
|
||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||
webSettings.setLoadsImagesAutomatically(true);
|
||||
webSettings.setAppCacheEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
// webView.getSettings().setJavaScriptEnabled(true);
|
||||
webSettings.setSupportZoom(true);
|
||||
webSettings.setBuiltInZoomControls(true);
|
||||
webView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
pb.setProgress(newProgress);
|
||||
if (newProgress >= 100) {
|
||||
pb.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
webView.loadUrl(url);
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webView = (WebView) findViewById(R.id.webView);
|
||||
webView.setOnClickListener(this);
|
||||
pb = (ProgressBar) findViewById(R.id.pb);
|
||||
mLayTopLeftTv = (RelativeLayout) findViewById(R.id.layTop_left_tv);
|
||||
mLayTopLeftTv.setOnClickListener(this);
|
||||
mLayTopTitle = (TextView) findViewById(R.id.layTop_title);
|
||||
mRight = (TextView) findViewById(R.id.right);
|
||||
mIvCode = (ImageView) findViewById(R.id.iv_code);
|
||||
mPb = (ProgressBar) findViewById(R.id.pb);
|
||||
mWebView = (WebView) findViewById(R.id.webView);
|
||||
mLayTopTitle.setText("智慧豆豆");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
default:
|
||||
break;
|
||||
case R.id.webView:
|
||||
break;
|
||||
case R.id.layTop_left_tv:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user