Use*_*ser 87 android click button
我必须OK在视图中的Click of Button 上打开一个URL .有人可以告诉你怎么做吗?
Par*_*han 223
在Button点击事件上写下这个:
Uri uri = Uri.parse("http://www.google.com"); // missing 'http://' will cause crashed
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
打开你的网址.
Button imageLogo = (Button)findViewById(R.id.iv_logo);
imageLogo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String url = "http://www.gobloggerslive.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Run Code Online (Sandbox Code Playgroud)