[英]Is not abstract and does not override abstract method onConnectionFailed(ConnectionResult)
[英]Not abstract and does not override abstract method
大家好,我有这个主班
public class Home extends ActionBarActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks, FriendsFragment.OnFragmentInteractionListener {
错误:(42,8)错误:Home不是抽象的,并且不会重写OnFragmentInteractionListener中的抽象方法onFragmentInteraction(String)
我创建了一个导航抽屉,并希望有一个新的片段来在Home Activity上显示另一个内容。
Android Studio告诉我使home.class抽象或实现抽象方法。
在这里里面:
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
public abstract void onFragmentInteraction(String id);
}
我做到了,但没有任何改变。 而且我无法将home类抽象化,因为那样就无法启动该应用了。
can't instantiate class com.myup2.up2.Home
编辑1:要调用Fragment,我想我正确实现了调用。
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();
}
}
感谢您的进阶阅读和帮助。
将此添加到您的活动中:
@Override
public void onFragmentInteraction(PUT PARAMETERS HERE IF ANY) {
//do something here, maybe switch to another fragment
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.