Style in android could not be set up - android

I'm having a problem in setting up the activity as: setSupportActionBar(toolbar);
method cannot be resolved.
can anyone help with it.
and yes I had already imported android.support.v7.widget.Toolbar;

Please verify that in your Activity you imported android.support.v7.widget.Toolbar instead of android.widget.Toolbar.
In addition verify your Activity inherits from AppCompatActivity instead of ActionBarActivity since google has deprecated it.

It seems that setSupportActionBar() method cannot be resolved because you may have extended AppBarActivity instead use.
public class MainActivity extends AppCompatActivity{

Related

Flutter: Extend FlutterActivity AND AppCompatActivity

I'm trying to create an android plugin for Flutter that depends on using an AppCompatActivity (as it has a method that takes the embedding appcompatactivity as a parameter).
However, since my main activity extends FlutterActivity, I cannot simultaneously extend AppCompatActivity. I tried implementing it instead, but failed because of some redundancies.
Is there any way to hack this?
Thanks
extend AppCompatActivity vs extend flutterActivity
you can find your answer here

getFragmentManager vs getSupportFragmentManager ERROR

i need help for this . I realize sth very strange about this. In order to disable the Action bar (Title) , i need to add in this code
requestWindowFeature(Window.FEATURE_NO_TITLE);
So this only works I change from
extends AppCompatActivity
To this
extends Activity
So after changing that, I got error for the getFragmentManager.
Please have a look at the screenshot. And let me know if u guys have any idea wads going on? THx
Use getSupportFragmentManager() instead of getFragmentManager().
AppCompatActivity is v4 library therefore required to use v4 functions
And to use it in Activity instead of Activity change it to FragmentActivity. Then you can use getSupportFragmentManager()
requestWindowFeature() is not supported in AppCompatActivity thats why you could not use that method with AppCompatActivity.
Also if you are using AppCompatActivity you need to use SupportFragment and if you use Activity then use Fragment.
If you are using this import import android.support.v4.app.Fragment;,
then you must use getSupportFragmentManager.
Hope this helps.
You have to use the Compat method getSupportFragmentManager() instead of the regular one.
That's because it returns an object of type android.app.FragmentManager which is the type of the object where you're trying to store it.
If you use the regular method getFragmentManager() it'll return an object of type android.app.FragmentManager, which is an incompatible type.

How to extend ActionBarActivity and YoutubeBaseActivity?

Is there a way I can extend both of these in a single activity? If yes, please share with me the source code.
From another SO answer:
To reduce the complexity and simplify the language, Android does not support multiple inheritance as it's based on Java programming language. Hence you can't extend both ActionBarActivity and YoutubeBaseActivity in a Single Activity.
The solution is pretty simple: use the YouTubePlayerFragment class. This does not pose any requirement on the Activity, leaving you with plenty of options for your theming.
Since the version 22.1.0, the class ActionBarActivity is deprecated. You should use AppCompatActivity.
Note : ActionBarActivity is deprecated, use AppCompatActivity.
Instead of having the Youtube player in the Activity (extending YoutubeBaseActivity), make your Activity extends from AppCompatActivity and use a YoutubePlayerFragment inside the AppCompatActivity. You will be able to use all the features of AppCompat with your Youtube video.
If you REALLY want to use BaseYoutubeActivity, you have to add an AppCompatDelegate in your own Activity extending the BaseYoutubeActivity and use it in every lifecycle method of your activity. Read the documentation of the delegate and read the original source code of AppCompatActivity to understand the delegate.
You cannot do that for now. you can use fragment instead of activity in your Activity that extends AppCompatActivity
Please refer to this answer. https://stackoverflow.com/a/30101931/4321808

ActionBar cannot be resolved as a type

I'm trying to learn how to make tabs in an android app. Reading through tutorials, I had the idea that we should implement the ActionBar.TabListener (to inherit the onTabSelected and other methods ) and getting fragments involved (so I can swipe the fragments), like this:
public class MainActivity extends FragmentActivity implements ActionBar.TabListener
However, Eclipse insists on telling me that ActionBar cannot be resolved as a type, and the suggested solusions is to create the interface, which is not helpful, thank you guys for your help
One possible problem of this, and it will give you an idea just for trying.
Add import android.app.ActionBar;
If you cannot import this package, then I think you have a problem with the Eclipse settings.
Another important thing, know that ActionBar.TabListener is deprecated by the latest API level 21, documentation # ActionBar.TabListener
I know its Bit late but hope someone will find it useful.
try importing ActionBar
import android.app.ActionBar;
if you can import it then try to implent tablistener like this
public class MainActivity extends FragmentActivity implements android.app.ActionBar.TabListener {
worked for me.

The method onActivityCreated(bundle) is undefined for the type SherlockFragment

I'm trying to work on a project that implements actionBarSherlock, I've added the library to the project properly and I get this error:
The method onActivityCreated(bundle) is undefined for the type SherlockFragment
This is the code from the project:
public class A_class extends SherlockFragment implements
OnClickListener { ... }
I think the answer is quite simple but I can't work it out. Any ideas?
There are two ways:
If you want to use a fragment with sherlock features use SherlockFragment. In this case you cannot have activity related method since its a "Fragment"
Otherwise you are looking for SherlockFragmentActivity

Categories

Resources