I just added ActionBarSherlock to my project using these instructions, and the project compiled. But I haven't been able to actually use the library. Trying to use getSupportActionBar() just yields a Cannot resolve method error.
I'm referencing the library at the top of the class. Actually, import com.actionbarsherlock.app.ActionBar and import com.actionbarsherlock.* came up in the suggestions dialog, but I've tried both separately, and both come with the warning Unused import statement. So it seems my project doesn't actually know there's a connection between getSupportActionBar() and the ActionBarSherlock library. Any ideas on why/how to fix it?
I bet that you extend an Activity and not a SherlockActivity
Also do not forget to use a Sherlock Theme
Related
I moved the NavigationTabbedActivity from one project to another, but I'm getting this error:
setSupportActionBar method cannot be found.
I've tried replacing the import widget.toolbar with import android.support.v7.widget.Toolbar; but it doesn't solve the problem.
Actually it needs the class to extend Activity but in my case the class already extends CustomActivity which in turn extends the default AndroidActivity, I tried extending customActivity with AppCombatActivity but it didn't work either. Is this error because I copied the file? Where am i wrong?
Ok while copying the file i forgot to add appcompat in the manifest file. so add the AppCompatActivity in the manifest file ie)
compile 'com.android.support:appcompat-v7:22.+'
and extended the custom activity to AppCompatActivity , and resynced the project , that solved the problem , thanks for your suggestions :)
Based on the small amount of information that was given I will try and provide a answer.
First of, when you copy a file over to a new project the activity doesn't exist in yourManifest.xml so make sure you declare it in your manifest.
You would also have to copy the layout file from the previous project or change it in your new one.
The next thing is the old project name will still be at the top and needs to be changed to the new project name.
My best advice would be to remove all the imports at the top and import everything again to make sure all the classes and everything is imported correctly.
actionBar = getActionBar(); is working fine In most of the new mobile sets, but in some old set it give error -
"application stopped unexpectedly"
Can somebody please tell me why it is so, or is there any alternatives for getActionBar(), like actionbar = new ActionBar(). I am not using support.v7
Start using v7 appcompat library, as it is the only way.
Read this : https://developer.android.com/topic/libraries/support-library/features.html#v7
Add this line in the build.gradle and re-sync:
compile 'com.android.support:appcompat-v7:23.2.0'.
Refractor your activity classes by extending to AppCompactActivity instead of Activity.
If you've set custom action bar, call setSupportActionBar([your_custom_toolbar]) in OnCreate() method.
You can now call getSupportActionBar() error-free :)
in your onCreate() function use this line to set your ActionBar.
getSupportActionBar().show();
Hope it solves the problem!
Older devices that you are using don't have the ActionBar; so the application crashes when you try to access it.
So, to support ActionBar on older devices, you can use the support library and use getSupportActionBar() to access it.
Instead of using the plain vanilla Activity, you should be using ActionBarActivity to be able to use the getSupportActionBar() method.
I am using eclipse for android development and last time I used it couple of months ago with API-17. But today when installing new updates from SDK manager, I am trying to create a new project. And after creation my activity is extending ActionBarActivity instead of activity. And its showing errors. Any solutions?
Plus I got the below 2 lines of importing showing error:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
you can manually remove these if you dont need them, but they are very useful as it creates overflow menu, action bar for lower android version of its own
Import the AppCompat library into Eclipse (you may have to download it from the SDK Manager first). ActionBarActivity works the same as a normal Activity, except some method names are slightly different, e.g. getSupportActionBar() instead of getActionBar() and getSupportFragmentManager() instead of getFragmentManager().
I downloaded the ADT Bundle directly from android website for my mac. Everything was fine until I created a new project, and eclipse created my project as well as a folder named "appcompat_v7".
But I don't it, because that way I can't follow the tutorial, since you can't extend a method more than 1 time for example:
public class MainActivity extends ActionBarActivity
What can I do ? I can't follow any tutorial. I was trying this one (https://www.youtube.com/watch?v=E780gbh6vLU) and I can't because I have that appcompat_v7 project. The same happens with this one (http://code.tutsplus.com/tutorials/android-sdk-create-a-barcode-reader--mobile-17162)
Please I really need help, for my university project.
You can make it extend Activity and use the android.app.* versions of various classes (Activity, Fragment, etc) instead. IN your styles.xml, make your base style extend an Android-provided theme (like Theme.Holo) instead of the AppCompat one.
I have the same issue has this post: android.support.v4.app.Fragment: undefined method getChildFragmentManager(). I need to use getChildFragmentManager() because I'm using nested fragments.
My problem is: the solution in the other post does not work for me:
My SDK is updated.
I got my android-support-v4 from the SDK folder.
I added android-support-v4 both the my project and ABS.
Here is my libs:
How can I correctly use this method?
Not sure if you've resolved your issue yet, but I was having the same issue and I resolved it. The getCildFragmentManager() method is a method of the class Fragment and not FragmentActivity. Just because your class extends fragment activity does not mean you'll have access to this method. What I did is I created an instance of my fragment in which I wanted to place the child fragment and invoked the method through that fragment instance. There are obviously other approaches to this, but this worked for me.
maybe something in your android manifest, look at the header or 'footer of your android manifest about minimum SDK version.
This is because by using old android.support.v4.
once you change the latest library.it will solved
I solved it by change it.
Hope it will work