Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 多个按钮处于活动状态时,按钮超链接不起作用_Android_Button_Hyperlink - Fatal编程技术网

Android 多个按钮处于活动状态时,按钮超链接不起作用

Android 多个按钮处于活动状态时,按钮超链接不起作用,android,button,hyperlink,Android,Button,Hyperlink,我想在活动中有几个按钮,当触摸它们时会转到Url,但只有一个按钮设置了链接,其他按钮会有不寻常的反应,不会设置文本和Url <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18dp"

我想在活动中有几个按钮,当触摸它们时会转到Url,但只有一个按钮设置了链接,其他按钮会有不寻常的反应,不会设置文本和Url

<TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18dp"
            android:textColor="#000000"
            android:text="@string/antivirus" />

        <Button
            android:id="@+id/antivirusbtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:background="#021f4e"
            android:text="Button"
            android:textColor="#ffffff"
            android:textSize="18dp" />

      <Button
            android:id="@+id/antivirusbt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="#021f4e"
            android:text="Button"
            android:textColor="#ffffff"
            android:textSize="18dp" />

关于java: @凌驾 创建时的公共void(Bundle savedInstanceState){ super.onCreate(savedInstanceState)

setContentView(R.layout.antivirus);
按钮链接=(按钮)findViewById(R.id.antivirusbtn);
link.setClickable(true);
setMovementMethod(LinkMovementMethod.getInstance());
字符串文本=”;
link.setText(Html.fromHtml(text));
按钮链接1=(按钮)findViewById(R.id.antivirusbtn2);
link1.可设置可点击(true);
setMovementMethod(LinkMovementMethod.getInstance());
字符串text1=“”;
link.setText(Html.fromHtml(text1));

只有当您希望文本视图显示为链接时,才需要设置移动方法和可点击性等(类似于此图像中的链接)

默认情况下,按钮是可单击的,您只需在浏览器中使用intent with Action_视图启动URL即可

   Uri uri = Uri.parse("http://www.abcd.com/faqs.html");
   Intent intent = new Intent(Intent.ACTION_VIEW, uri);
   startActivity(intent);

为什么要使用按钮而不是文本视图呢?我检查了它,但也有同样的问题。
   Uri uri = Uri.parse("http://www.abcd.com/faqs.html");
   Intent intent = new Intent(Intent.ACTION_VIEW, uri);
   startActivity(intent);