Tuesday, February 26, 2013

[android-developers] Re: TextView vs Button

Well, a look at the source code reveals that Seshu has a point. There is virtually no difference between a Button and a TextView:

public class Button extends TextView {
    public Button(Context context) {
        this(context, null);
    }

    public Button(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.buttonStyle);
    }

    public Button(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
}


On Tuesday, February 26, 2013 8:24:53 PM UTC-6, Lew wrote:
skink wrote:

Seshu wrote:
>      I have one textview [sic] and one button [sic]. i [sic] know the purpose of both 
> views but if i [sic] used background image and displayed text on both then 
> both r [sic] looking same only. Is there any particular point which 
> differentiate them.
 

you'll answer your question by yourself when you see the source code
of Button.java, just use good, old uncle Google

Never mind the source. You shouldn't have to read source to figure out how to use an API.

From the Javadocs: 

"Represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action."
"... instead of applying an OnClickListener to the button in your activity, you can assign a method to your button in the XML layout, using the android:onClick attribute."

"Displays text to the user and optionally allows them to edit it. "

Seems like points to differentiate them are already revealed.

-- 
Lew

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment