2013-03-20 13 views
5

mam ten problem ..Metoda add (int, Fragment, String) w typie FragmentTransaction nie dotyczy argumentów (int, fragment String)

The method add(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, Fragment, String) 

przy użyciu następującego kodu Wewnątrz FragenmtActivity

getSupportFragmentManager().beginTransaction().add(com.korovyansk.android.slideout.R.id.slideout_placeholder, ((Fragment)new CommentsMenuFragment()), "menu").commit(); 

gdzie realizacja CommentsMenuFragment jest:

public class CommentsMenuFragment extends Fragment { 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View view = inflater.inflate(R.layout.fragment_comment, container, false); 
     ListView lvComments = (ListView) view.findViewById(R.id.lvComments); 



     return view; 
    } 

} 
+4

Czy używasz pliku android.support.v4.app.Fragment lub android.app.Fragment? –

+0

Dzięki, znalazłem odpowiedź na to w następującym pytaniu http://stackoverflow.com/questions/11753921/error-in-fragment – Adham

Odpowiedz

29

Chec k jeśli twoje KomentarzeMenuFragment rozciąga się od android.support.v4.app.Fragment zamiast android.app.Fragment.

+1

pomogło mi, mój Fragment został zaimportowany jako android.app.fragment, zmieniłem importuj do android.support.v4.app, a błąd dodawania mojego FragmentActivity Disapeared. Dzięki @PaNaVTEC –

Powiązane problemy