Android Sliding Tabs With Material Design issue - android

I am creating a demo project for sliding tab with material design.
When I am doing like below :
public class MainActivity extends ActionBarActivity { // source code}
It will show red line on "ActionBarActivity". It is not allows for extends.
I have follow steps from http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html
Any help would be greatly appreciated.

Since the version 22.1.0, the class ActionBarActivity is deprecated. For better approach you should use AppCompatActivity
Just change your dependency,Like :
compile "com.android.support:appcompat-v7:22.1.0"

FYI, ActionBarActivity is deprecated but it should not show red lines, that is an error indication probably due to import! Use AppCompatActivity introduced in support V7 library.

Related

I want to make an app which uses more of Fragments, so which Class to extend in MainActivity?

Now as default AppCompatActivity is extended by default by Android Studio.
But if I am going to use more of fragments, then is it wise to use Fragment Activity or Activity instead of AppCompatActivity ?
On Developer.android site, they mentioned this :
↳ android.app.Activity
↳ android.support.v4.app.FragmentActivity
↳ android.support.v7.app.AppCompatActivity
Activity is our simple Activity without action bar.
Fragment is our simple Fragment and FragmentActivity if you want to use getSupportFragmentManager()
ActionbarAcvity if you want to use action bar in activity which is deprecated in 5.0. To support action bar in 5.0 and prior use AppCompatActivity.
Hope it helps.
The answer for all modern app development, since Android 5.0 Lollipop came out and introduced the appcompat library, is to extend AppCompatActivity and use support fragments (getSupportFragmentManager instead of getFragmentManager.)
There's no good reason not to; the support and appcompat libraries have caught up to the framework in every feature and boast much wider compatibility.

new features / enhancements for AppCompatActivity comparing with ActionBarActivity [duplicate]

android.support.v7.app.AppCompatActivity was added into the latest v7 support library as a new feature yesterday.
It is said that ActionBarActivity has been deprecated in favor of the new AppCompatActivity and that AppCompatActivity is base class for activities that use the support library action bar features. So, what are new features of AppCompatActivity over ActionBarActivity? What enhancements do AppCompatActivity have over ActionBarActivity? And what are advantages of AppCompatActivity? Could somebody supply a few samples?
PS: what surprised me most is that AppCompatActivity which is extended from android.support.v4.app.FragmentActivity is the direct parent class of ActionBarActivity! I mean actually now that ActionBarActivity can do anything that AppCompatActivity can do, why did Android pushed out the latter?
Meanwhile, I saw a blog post that states: "It's not a rename from ActionBarActivity to AppCompatActivity, the internal logic of AppCompat is available via AppCompatDelegate", so what's the "internal logic" of AppCompat? What can AppCompatDelegate do? Could somebody post some code about this?
As Chris wrote, new deprecated version of ActionBarActivity (the one extending AppCompatActivity class) is a safe to use backward compatibility class. Its deprecation is just a hint for you asking to use new AppCompatActivity directly instead. AppCompatActivity is a new, more generic implementation which uses AppCompatDelegate class internally.
If you start a new development, then you should rather use new AppCompatActivity class right away. If you have a chance to update your app, then replace deprecated ActionBarActivity by the new activity as well. Otherwise you can stay with deprecated activity and there will be no difference in behavior at all.
Regarding AppCompatDelegate, it allows you to have new tinted widgets in an activity, which is neither AppCompatActivity nor ActionBarActivity.
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 of those overridden methods forward the calls to the inner AppCompatDelegate instance. AppCompatDelegate will do the rest and your "old-fashion" activity will be "materialized".
It's mostly a name change: ActionBarActivity doesn't really describe everything it now does. You can safely use ActionBarActivity if you wish to. Think of it like a symlink.
The AppCompat Support Library started with humble, but important beginnings: a single consistent Action Bar for all API 7 and higher devices. In revision 21, it took on new responsibility: bringing material color palette, widget tinting, Toolbar support, and more to all API 7+ devices. With that, the name ActionBarActivity didn’t really cover the full scope of what it really did.
http://android-developers.blogspot.it/2015/04/android-support-library-221.html
AppCompatActivity was introduced into Android-SDK since the release of android support appcompat library.
AppCompatActivity is the direct child class of FragmentActivity of support v4 and the direct parent class of ActionBarActivity.
AppCompatActivity is the base class for activities that use the support library action bar features.
You can add an ActionBar to your activity when running on API level 7 or higher by extending this class for your activity and setting the activity theme to Theme.AppCompat or a similar theme.
As for support v7 appcompat library, it adds support for the Action Bar user interface design pattern. This library includes support for material design user interface implementations.
Here are a few of the key classes included in the v7 appcompat library:
ActionBar - Provides an implementation of the action bar user
interface pattern.
AppCompatActivity - Adds an application activity class that can be
used as a base class for activities that use the Support Library
action bar implementation.
AppCompatDialog - Adds a dialog class that can be used as a base
class for AppCompat themed dialogs.
ShareActionProvider - Adds support for a standardized sharing action
(such as email or posting to social applications) that can be
included in an action bar.
After you download the Android Support Libraries, this library is located in the /extras/android/support/v7/appcompat/ directory.
Previously the only entry point into AppCompat was through the now deprecated ActionBarActivity class. Unfortunately this forced you into using a set Activity hierarchy which made things like using PreferenceActivity impossible.
see chris banes's support-libraries-v22-1-0 for more info
The latest release of android support library, 22.1, deprecates the ActionBarActivity in favor of AppCompatActivity, which promises to bring a single consistent ActionBar for all devices starting with API Level 7 and above

New Blank Activity extends ActionBarActivity

I have a strange "problem" on my Android Studio 0.9.9, and still on the version 1.
Since this update, when i create a new project android studio doesn't create a blank activity. It should be "MainActivity extends Activity", but it's "MainActivity extends ActionBarActivity"
I have a second problem as well. When i'm editing Layout Files, on the Preview of the Layout, i can't see the ActionBar (But i don't have this problem when i'm editing previous project)
I really don't know where this problem is coming from. Maybe a problem in the configuration of Android Studio, but i didn't change anything. Or maybe it's just some new features.
I'm new in Android Development so it might be my lack of knowledge.
Has Someone had this problem before ? Any hint or advice on this?
Is my explanation lucid?
Thanks for your help !
EDIT :
After some search, i found some post from StackOverflow :
By default android creating new project as ActionBarActivity
Create New Activity adds an activity which extends Activity class instead of ActionBarActivity class in Eclipse
android adt bundle automatically extending ActionBarActivity and adding fragments and more stuff?
Update May 4th, 2015:
Starting with Support Library 22.1 (blog post):
In this release, ActionBarActivity has been deprecated in favor of the new AppCompatActivity.
Original Post:
Has Someone had this problem before ? Any hint or advice on this?
This is not a problem but intended to help you apply the new design language by Google, named Material Design. One major change is the new UI widget called Toolbar. To use it you have to extend from ActionBarActivity as mentioned in a recent blog post by the Android developers. In this blog post you will also find more information about the Toolbar widget.
So if you're new, Google is just trying to help you to get right on track with the new elements and styles.
In your resources xml file, your Action Bar style should have a parent. Something like:
<style name="MyActionBar" parent="#style/Widget.THE_STYLE_YOU_WANT"> //HoloDark, MaterialLight, ect
<item name="android:background">custom color</item>
</style>
i also feel strange for that it extends the actionbaractivity,some days before when i create a project and set minsdk to 14,it extends activity and use holo theme when under lollipop ,but today i do the same thing and found it didn't derive from the activity and use the appcompat theme only,indeed one new feature for appcompat library is that it Added support for material design user interfaces. maybe extends actionbaractivity is for the sake of using the newest theme,because under lollipop you can't use material theme,use appcompat is the quickest way, i don't know google's manner for the holo theme now.

Android AppCompat Library usage

I found on many blogs and tutorials links, where clearily written to support AppCompat Library we should use ActionBarActivity to extend Class instead of normal Activity.
So its clear to me, but i have few doubts in my mind regarding extending ActionBarActivity.
Questions are:
what if my class extends Fragment (is there i need to extends ActionBarActivity) while using AppCompat Library?
what if my class extends ListActivity (is there i need to extends ActionBarActivity) while using AppCompat Library (if 'yes' so how ?)
1) ActionBarActivity extends FragmentActivity so you can use fragments with it
2) Instead of using ListActivity you have to add a ListFragment to your ActionBarActivity (or FragmentActivity). You can add it to android.R.id.content so it occupies the whole screen.

How to combine sherlock and viewpageindicator?

Hey I am new in android develop.
I am now try to use both sherlock library and viewpageindicator together, but I can't.
Could you post tutorial how we combine those two ?
Thank
Below is the link which contains sample program for combining sherlock and view page indicator.
https://github.com/JakeWharton/Android-ViewPagerIndicator/
I hope you to study the full sample and analyse whole program you can understand the concept easily .
This will provide a useful information for you my friend.
You should modify Shelock Action Bar source code a little bit (change extends from Activity to FragmentActivity)
From:
public abstract class SherlockActivity extends Activity
To:
public abstract class SherlockActivity extends FragmentActivity
(for implement View Page Indicator)
And then, build Sherlock Action Bar lib again, use it like normal.

Categories

Resources