OnClick() method doesn't work in TextView

I have a textView with OnClick method to navigate another activity. But, If i pressed that text it doesn't navigate. But If i used Button instead TextView, it works perfectly. Can't use OnClick method in TextView?

My XML Code;

<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" />

My Java Code:

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

Answers


Add this attribute to textview

       android:clickable="true"

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

android:clickable

Defines whether this view reacts to click events.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol clickable.

Related Methods setClickable(boolean)


Need Your Help

how to play you tube video within my android application

android android-layout android-intent android-fragments android-activity

i have placed a picture in my android activity. when user taps on that picture i want a you tube video should be played within my app.

Changing an int value into time using casting and setfill

c++ casting

For a programming assignment, I need to display the time a hypothetical cafe is open. On the weekends the cafe opens an hour and a half later than during the week, but closes at the same time.

What is the best way to load ASP page in my ASPX page?

asp.net parsing asp-classic

I'm working with a partner who gives me tools in Classic ASP.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.