Already here 3 day I can not understand the fragments. Here is such a list of www.androidbegin.com how can I remake it as a fragment so that it will be called up with this method. I didn’t catch up with a lot of source codes, the most primitive

if (drawerItem.getIdentifier() == 1) { getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, new Fragment1()).commit(); } 
  • The question itself is not visible. What exactly is your problem? - Yuriy SPb
  • www.androidbegin.com for example link on the activity. I need to translate this into fragments so that when getSupportFragmentManager opens the foliage with parsernnym pages - Artem
  • And what's the problem then? getSupportFragmentManager() red, probably, underlines? - Yuriy SPb
  • No, this is not the problem. In the link example there everything is on activities. Link - Artem
  • Well, yes, if you put a fragment of an activation, then it is red - Artem

1 answer 1

In fragments there are no these methods. They are in activation. Write so

 getActivity().method(); 
  • You probably did not understand getSupportFragmentManager nothing to do with it at all - Artem
  • What I need is to translate from the activity of MainActivity.java into a fragment of what is in the link - Artem
  • one
    @Artem, the link is an extremely outdated example. There are no many activation methods in the fragment. Markup is prescribed there differently. You do not expect that someone here will rewrite the entire code from the link? You need to go on the other hand - to implement an example of the simplest fragment, and having figured it out with them in the black, trying to do something else. - Yuriy SPb
  • Yes, I saw a lot of examples and everything is complicated for me. I still can not understand this data transfer between fragments and activities. voosche found examples through Serialization - Artem
  • @Artyom, well, start with a few simplest lessons like startandroid.ru/ru/uroki/vse-uroki-spiskom/ ... Do not immediately try to redo something under the fragments. First, simply "Hello" in the fragment output. And further complicate. At the moment, that whoever has not written you your knowledge base will not be enough for effective understanding. - Yuriy SPb