dee*_*thi 8 android android-button url-redirection
我想Button在Android App中点击时将用户重定向到特定的URL .
ziy*_*iya 22
您可以启动"查看"活动,该活动将是给定URL的浏览器:
public class HelloWorld extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Assuming you are using xml layout
Button button = (Button)findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("http://www.stackoverflow.com/"));
startActivity(viewIntent);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24908 次 |
| 最近记录: |