安卓中点击某个按钮跳转到指定网页

来源:互联网 发布:照片编辑软件下载 编辑:程序博客网 时间:2024/06/05 02:29

         在安卓代码中有时候会要求点击某个按钮跳转到指定网页,整理如下:

       

                <span style="font-size:14px;">Button  btn = (Button)findViewById(R.id.button);</span>//按钮id                btn.setOnClickListener(<span style="color:#0000ff;">new</span> View.OnClickListener(){ //按钮监听事件                    public void onClick(View v){<pre name="code" class="java">                        Uri uri = Uri.parse("http://baidu.com");  //指定网址                        Intent it = new Intent(Intent.ACTION_VIEW,uri);                        startActivity(it)
}
});




0 0