Java 错误:(22116)错误:不兼容的类型:无法将片段转换为BottomPictureFragment

Java 错误:(22116)错误:不兼容的类型:无法将片段转换为BottomPictureFragment,java,android,android-fragments,Java,Android,Android Fragments,这与教程中的代码相同,但当我尝试使用该代码时。它给了我上面的错误 package com.example.rishav_pc.fragments; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends AppCompat

这与教程中的代码相同,但当我尝试使用该代码时。它给了我上面的错误

package com.example.rishav_pc.fragments;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends AppCompatActivity implements TopSectionFragment.TopSectionListner {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

// This gets called by the top fragment when the user clicks the button
@Override
public void createMeme(String top, String bottom) {

    BottomPictureFragment bottomFragment = (BottomPictureFragment) getSupportFragmentManager().findFragmentById(R.id.fragment2);
    bottomFragment.setMemeText(top, bottom);
}

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

@Override
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 == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}
还有一个错误

Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.

BottomPictureFragment
中,将扩展类
Fragment
的导入更改为
import android.support.v4.app.Fragment。你似乎认为这是另外一回事。你应该有这样的东西:

import android.support.v4.app.Fragment;
...
public class BottomPictureFragment extends Fragment { ... }