Toolbar mainly should used with ActionBarActivity
if I want to use it by Extends Activity it gives an error
when I call
setSupportActionBar(toolbar);
I main Above I don,t want to use ActionBarActivity
Any help here , And what About Another kind Of Activities
Like FragmentActivity or Others .
Example to support FragmentActivity
ActionBarActivity activity = (ActionBarActivity) getActivity();
activity.setSupportActionBar(toolbar);
If you're extending Activity just use setActionBar(). setSupportActionBar is for when your're using ActionBarActivity from the support library
You have done little mistake .. you had to extend
ActionBarActivity
not only
Activity
class ..when you do error will be removed.
Related
My main activity extends AppCompatActivity where I create and inflate my menu. I also want my main activity to contain a map fragment. This requires that my main activity extends FragmentActivity, but I cannot extend from two super classes. How am I supposed to add a map fragment to my main activity?
AppCompatActivity extends FragmentActivity, so you get all of the functionality in FragmentActivity by extending AppCompatActivity.
Well, AppCompatActivity already extends FragmentActivity, so there should be no problem.
I developed an app, but now I want to change all the Activities.
They all should have an ActionBar.
Can I directly convert my code by extending the existing Activities to get an ActionBar?
I would really appreciate any help.
-Agree with above answer. doing as per follow ..
public class YourActivity extends ActionBarActivity{
}
-And..You have to add this code into your manifest file
android:theme="#style/Theme.AppCompat"
-Under application tag
Definitely you can, like this, just you will need is Android Support Library (AppCompat lib)
public class YourActivity extends ActionBarActivity
And also do necessary changes regarding with ActionBar, you can get ActionBar object like ,
ActionBar mAction = getSupportActionBar();
mAction.setTitle("Your Title");
Since the new Android SDK Update I have a ActionBarActivity for my MainActivity.
Before that is was a normal activity and I just replaced it with the: ListActivity
How can I add use the ListActivity in my new MainActivity which is a ActionBarActivity?
You can get rid of extends ActionbarActivity and extends ListActivity. You could also use ListFragment.
You can extend ActionBarActivtiy and use ListFragment from the support library
http://developer.android.com/reference/android/support/v4/app/ListFragment.html
I'm using CalendarDatePickerDialog from BetterPickers in my project,
if i use a FragmentActivity, then i can use the getSupportFragmentManager().
The problem is that i'm trying to add CWAC-Camera as well,
but for that i need to use
getFragmentManager() in a regular Activity which breaks the BettePickers.
any ideas?
Try to extends FragmentActivity and implements CalendarDatePickerDialog.OnDateSetListener
Change your Activity to FragmentActivity.
Use the newInstance(YouActivity.this)
Enjoy!
hi i've an app where i want to implement setVolumeControlStream
but i can't because my class extends TabActivity not Activity. what shall i do ??
setVolumeControlStream() is available on TabActivity, because TabActivity inherits from Activity.