点击子条目传值url跳转到对应的WebView

//MyBaseAdapter中(写在返回值 return convertView 前面)

xLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView parent, View view, int position, long id) {
        Intent intent = new Intent(context, WebViewActivity.class);
        intent.putExtra("url", results.get(position - 1).getUrl());
        context.startActivity(intent);
    }
});

//WebViewActivity中

public class WebViewActivity extends AppCompatActivity implements View.OnClickListener {

    private WebView main_web;
    private ProgressBar web_progressBar;
    private ImageView web_back;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //显示当前页面布局
        setContentView(R.layout.webview);
        //获取资源ID
        main_web = (WebView) findViewById(R.id.web_view);
        web_back = (ImageView) findViewById(R.id.web_back);
        web_progressBar = (ProgressBar) findViewById(R.id.web_progress);
        //接收传过来的值
        Intent intent = getIntent();
        String url = intent.getStringExtra("url");
        web_back.setOnClickListener(this);
        main_web.loadUrl(url);
        main_web.setWebChromeClient(new WebChromeClient(){

            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                web_progressBar.setProgress(newProgress);
            }
        });
    }

    @Override
    public void onClick(View v) {
        this.finish();
    }
}

你可能感兴趣的:(点击子条目传值url跳转到对应的WebView)