安卓开发fragment报错_如何解决'类型不匹配:不能从android.app.FragmentManager转换为android.support.v4.app.FragmentManager`错误...
I am getting the following errorType mismatch: cannot convert from android.app.FragmentManager to android.support.v4.app.FragmentManagerfor the following lineFragmentManager frgManager = getFragmentMa
I am getting the following error
Type mismatch: cannot convert from android.app.FragmentManager to android.support.v4.app.FragmentManager
for the following line
FragmentManager frgManager = getFragmentManager();
frgManager.beginTransaction().replace(R.id.content_frame, fragment).commit()
I have the following imports in my class
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
How to fix the error?
解决方案
Replace getFragmentManager() with getSupportFragmentManager(), and make sure your class is a subclass of FragmentActivity.
更多推荐
所有评论(0)