简体   繁体   English

如何在单击android中的按钮时重定向到特定的URL?

[英]how to redirect to particular URL while clicking on button in android?

我想在点击Android应用中的Button时将用户重定向到特定的URL。

You can start a 'view' activity, which would be the browser given a URL: 您可以启动“查看”活动,该活动将是给定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);
      }
    });

  }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击Android WebView上的任意位置后,重定向到特定URL - Redirect to a particular URL after clicking anywhere on an Android WebView 使用 Ionic 框架单击 Android 设备后退按钮时如何重定向到特定页面 - How can i redirect to a particular page when clicking Android device Back button using Ionic Framework 在单击按钮时,如何在android片段中重定向到Webview页面? - While clicking a button how can i redirect to webview page in android fragment? 如何在android中单击按钮时更新微调器值? - how to update the spinner values while clicking on button in android? 如何在单击按钮时在Android中获取复选框,带有ListView值的EditText? - How to get checkbox,EditText with ListView values in android while clicking a button? 如何在Android的ListView中单击按钮时获取自定义对话框活动? - How to get custom dialog activity while clicking on a button in listview in android? 如何通过单击在 Android 中选择特定的 TextView 并通过按钮设置其文本 - How to select a particular TextView in Android by clicking it and set its text through button 如何在单击按钮时显示图像并通过在android studio中按特定方向滑动来滑动图像选项? - how to display image upon clicking the button and slide the image option by swiping in the particular direction in android studio? 单击Android按钮重定向到URL - Re-direct to an URL on clicking Android Button 单击按钮时,Android崩溃。 - Android Crash while clicking the Button.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM