Inconvertible type error when creating fragments

0 Julian Gaines · February 19, 2015
I am trying to simulate my fragment code based off bucky's video.  I followed his steps in creating the topsectionfragment and the bottompicture fragment.  In the when I created the createMeMe method and tried to to import the bottompicture fragment into java it gives me an error saying that: inconvertible types: cannot cast '' to 'com......BottomPictureFragment'.  I not sure what this message means.  Can someone help please.  Here is my MainActivity code below.

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity implements TopSectionFragment.TopSectionListener{

    protected void onCreate(Bundle savedInstanceState) {

    //this gets called by the Top Fragment when the user clicks the button
    public void createMeme(String top,String bottom) {
        BottomPictureFragment bottomFragment = (BottomPictureFragment) getSupportFragmentManager().findFragmentById(;
        //bottomFragment.setMemeText(top, bottom);

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == {
            return true;

        return super.onOptionsItemSelected(item);

Post a Reply


Oldest  Newest  Rating
+2 Bartosz MaciÄ™ga · March 29, 2015
I think this problem is very simple, you must  check if when you`re creating BottomFragment you`re using because you when you`re using  "getSupportFragmentManager", if you use in BottomFragment you must use "getFragmentManager" .

Just check your imports in BottomFragment and use proper FragmentManager.
0 Rip Van Winkle · August 7, 2015
Thanks, Bartosz! That's the missing information I needed to get the MemeCreator example (from android tutorial lessons 22-30) to work.  After changing  "import" to "import" in and, I just needed to change "getSupportFragmentManager" to "getFragmentManager" and then it finally ran successfully.
0 manoj kumar · June 5, 2015
" getFragmentManager " solved the problem !!! Thanks dude !!
0 Mike · March 29, 2015
hi guys what can I do to solve this problem?
0 Zahid Khan · October 2, 2015
Thanx bro. it solved my problem too..
0 Ghanshyam doifode · September 24, 2015
thanx dude..
Bartosz Maci?ga 
0 Dol Lod · February 19, 2015
I was just having a similar problem about an hour ago. However what I understand is that and; are two very different types of fragments. Think of the v4 fragments as basic fragments that are compatible with API's  of level 11 and onward and only supports a subset of features provided by is when fragment support is guaranteed for higher level API's and consequently has many subclasses of particular kinds of fragments such as the one you are trying to use that v4 fragments cannot support. 

I would first check for consistency in the import of fragment you are using. At least on Windows, when I extended Fragment by default, it use instead of

However, my guess is that you are probably using appv4 fragments, but the feature you are referring to only belongs to and so you need to decide whether you want to use v4 fragment or 

I am not that familiar with fragments either, but this like I said is what I just googled to solve my own issue. I hope it helps. 
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator