package com.bwie.zhanshi;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.bwie.adapter.MyPagerAdapter;
import java.util.ArrayList;
public class WebActivity extends AppCompatActivity {
private WebView web_view;
private ViewPager viewpager;
private ArrayList<Integer> list;
private MyPagerAdapter pAdapter;
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what==0){
int currentItem = viewpager.getCurrentItem();
currentItem++;
viewpager.setCurrentItem(currentItem);
handler.sendEmptyMessageDelayed(0,2000);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
viewpager = findViewById(R.id.view_pager);
web_view = findViewById(R.id.web_view);
//网页
//传值
String stringExtra = getIntent().getStringExtra(“pic”);
WebSettings settings = web_view.getSettings();
settings.setJavaScriptEnabled(true);
web_view.setWebViewClient(new WebViewClient());
web_view.setWebChromeClient(new WebChromeClient());
web_view.loadUrl(stringExtra);
//无限轮播
list=new ArrayList<Integer>();
list.add(R.drawable.a);
list.add(R.drawable.b);
list.add(R.drawable.c);
list.add(R.drawable.d);
pAdapter=new MyPagerAdapter(list,WebActivity.this);
viewpager.setAdapter(pAdapter);
handler.sendEmptyMessageDelayed(0,2000);
}
}