OnClick()方法在TextView中不起作用

用户名

我有一个textViewwithOnClick方法来浏览另一个活动。但是,如果我按该文本,它将无法导航。但是,如果我Button改用TextView,它会完美运行。无法OnClick在中使用方法TextView

我的XML代码;

<TextView
    android:onClick="webClick"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/textView1"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="19dp"
    android:text="Chapter 1"
    android:textSize="25dp" />

我的Java代码:

public void webClick(View v) {
    Intent intent = new Intent(this, Webview.class);
    startActivity(intent);
}
拉贡南丹

将此属性添加到textview

       android:clickable="true"

http://developer.android.com/reference/android/view/View.html#attr_android:clickable

android:clickable

定义此视图是否对单击事件作出反应。

必须为布尔值,“ true”或“ false”。

这也可能是对包含此类型值的资源(形式为“ @ [package:] type:name”)或主题属性(形式为“?[package:] [type:] name”)的引用。

这对应于可单击的全局属性资源符号。

相关方法setClickable(boolean)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章