How to create an inclusive aar file in Android?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.