大家好,我有这个主班的家
public class Home extends ActionBarActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks, FriendsFragment.OnFragmentInteractionListener {错误:(42,8)错误: Home不是抽象的,也不覆盖OnFragmentInteractionListener中的抽象方法OnFragmentInteractionListener(String)
我创建了一个导航抽屉,并且希望有一个新的片段来显示另一个内容,然后显示在Home活动上。
Android告诉我如何使home.class变得抽象或实现一个抽象方法。
在这里:
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
public abstract void onFragmentInteraction(String id);
}我这么做了但什么都没变。我不能让家庭课程变得抽象,因为它不再启动应用程序了。
can't instantiate class com.myup2.up2.Home编辑1:调用片段,我认为我正确地实现了调用。
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransac = fragmentManager.beginTransaction();
Fragment newFragment = null;
Bundle args = new Bundle();
switch(position) {
case 0:
break;
case 1:
break;
case 2:
newFragment = new FriendsFragment();
break;
}
if(newFragment != null) {
fragmentManager.beginTransaction()
.replace(R.id.container, newFragment)
.commit();
}
}感谢你在高级阅读和帮助。
发布于 2014-11-29 17:58:26
将此添加到您的活动中:
@Override
public void onFragmentInteraction(PUT PARAMETERS HERE IF ANY) {
//do something here, maybe switch to another fragment
}https://stackoverflow.com/questions/27204910
复制相似问题