Issue
Android - I am going to develop an app which API is between API 15 and the latest API.
But I have one question regarding "Java class extends".
What is the difference between:
Java class
extends AppcompatActivity, andJava class
extends Activity, andJava class
extends ActionBarActivity.
If someone give a clear definition, I will definitely tick the answer as accepted for my question.
Solution
- extending
ActionBarActivitygives you theActionBars functionality on every API level >= 7 - by extending
Activityyou can avoid adding additional projects/libraries to your project but you'll lack theActionBaron api levels below 11
ActionBarActivity is part of the Support Library. Support libraries are used to deliver newer features on older platforms. For example the ActionBar was introduced in API 11 and is part of the Activity by default (depending on the theme actually). In contrast there is no ActionBar on the older platforms. So the support library adds a child class of Activity (ActionBarActivity) that provides the ActionBar's functionality and UI
- The new deprecated version of
ActionBarActivity(the one extendingAppCompatActivityclass) is a safe to use backward compatibility class. Its deprecation is just a hint for you to use newAppCompatActivitydirectly instead.AppCompatActivityis a new, more generic implementation which usesAppCompatDelegateclass internally.
For instance, you inherit an activity from an external library, which, in turn, does not inherit from AppCompatActivity but you want this activity to have tinted materials widgets (views). To make it happen you need to create an instance of AppCompatDelegate inside your activity, override methods of that activity like addContentView(), setContentView() etc. (see AppCompatDelegate javadoc for the full list of methods), and inside those overridden methods forward the calls to inner AppCompatDelegate instance. AppCompatDelegate will do the rest and your "old-fashion" activity will be "materialized".
Answered By - activesince93
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.