Hi everyone I have this Main Class Home
public class Home extends ActionBarActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks, FriendsFragment.OnFragmentInteractionListener {
Error:(42, 8) error: Home is not abstract and does not override abstract method onFragmentInteraction(String) in OnFragmentInteractionListener
I created a Navigation Drawer, and want to have a new Fragment to show another Content then on the Home Activity.
Android Studio tells me to make the home.class abstract or to implement an abstract method.
Inside here:
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
public abstract void onFragmentInteraction(String id);
}
I did that but nothing changed. And I cant make the home class abstract because then its not starting the app anymore.
can't instantiate class com.myup2.up2.Home
Edit 1: To call the Fragment I think I implemented the call correctly.
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();
}
}
Thanks for reading in advanced and helping.
add this to your activity :
@Override
public void onFragmentInteraction(PUT PARAMETERS HERE IF ANY) {
//do something here, maybe switch to another fragment
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.