ActionBarActivity and FragmentActivity ... "Inconvertible types"?

I am currently having a curious problem trying to use the v4 and v7 compatibility libraries (actionbar) at the same time.

Let's say I have my own Activity class that extends ActionBarActivity, on the one hand, and, on the other hand, a fragment inside which I call "MyActivity" getActivity () ".

I checked the import, and my Fragment is fragment v4.

In v4 fragment, calling the getActivity () function returns FragmentActivity.

I also checked: ActionBarActivity extends FragmentActivity.

Now here is my problem: I have no errors in the editor (no red line). I am using Android Studio. When I try to "Make" a project, the compiler returns an error every time I call "getActivity" inside my fragment. He tells me that he has a FragmentActivity, but ActionBarActivity is expected and says that these classes are incompatible. It is interrupted, and I can’t even test my application.

This may be a gradle configuration problem, but I added the "compile" compilation of "com.android.support:appcompat-v7:18.0.+" "in the" dependencies "section of my build.gradle file, as said on this page:" http : //developer.android.com/tools/support-library/setup.html "and that doesn’t change anything ...

Any idea?

: , , Android-Studio :

, :

...
import android.support.v7.app.ActionBarActivity;
...
public abstract class MyAbstractActivity extends ActionBarActivity{
    //Do some stuff here
}

.

:

...
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
...
public class MyFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //Do some stuff...
        ((MyAbstractActivity)getActivity()).getSupportActionBar().setTitle(R.string.app_name);
    }

    //Do some stuff...
}

. "" , " ":

5 0 4

"Messages Make" , "getActvity()" "MyAbstractActivity":

java: : com.myapps.abstracts.MyAbstractActivity : android.support.v4.app.FragmentActivity

+4
2

, , , , Eclipse, , Eclipse. " ", , , , . , , Android Studio, ... , Eclipse... .: (

+2

Android Eclipse flaky. , . Eclipse. . , ant clean; ant debug ', , Eclipse .

0

All Articles