Why do some android programmers uses View class to create buttons?
-
I'm currently learning Android programming and the way I used to create command buttons in the activity class (not xml) is to "import android.widget.Button;" and then to create the Button instance such as " Button exit = (Button) findViewById(R.id.exitButton); " But I have came across some source code file that contains a View instance that is being used as a button. The rest of the code seems to be similar but the only difference is he is using View class instead of Button class. Can someone please tell me the difference between these two methods? Thanks in advance!
-
Answer:
There is not much difference. Think of widget as custom and ready-to-use View. In developer site it says: "The widget package contains (mostly visual) UI elements to use on your Application screen. You can design your own" http://developer.android.com/reference/android/widget/package-summary.html And if you design your own widget you have to extend View as well. So you're making use of View whether you're using View (directly) or widget (indirectly). Take a look at the android.widget.Button hierarchy at the top of: http://developer.android.com/reference/android/widget/Button.html
Madurang... at Yahoo! Answers Visit the source
Related Q & A:
- Why is the size of an empty class not zero in C++?Best solution by geeksforgeeks.org
- How to add new view at the top of an existing view in Android?Best solution by Stack Overflow
- Why are experienced programmers so hostile toward beginners?Best solution by Meta Stack Overflow
- Why am I not able to view, delete, or forward my mail in my inbox?Best solution by Yahoo! Answers
- What is one technique Raphael Sanzio uses to create emphasis in Marriage of the Virgin?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.