Suppose I have a Fragment, and in it an icon. Her id android:id="@+id/myIcon" .

This snippet along with another one connects to edit_activity.java. fr1 is our fragment.

 //Pager TabsViewPagerAdapter adapter = new TabsViewPagerAdapter(getSupportFragmentManager()); adapter.addFragment(fr1, "1"); adapter.addFragment(fr2, "2"); viewPager.setAdapter(adapter); 

Hooked up, yes. How do I get this icon in edit_activity? That is, let us assume, I would search for a normal element through findViewById() , and an element from a fragment?

    1 answer 1

    In its fragment in the onCreateView method:

     @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.my_fragment, container, false); ImageView icon = (ImageView ) view.findViewById(R.id.myIcon); return view; } 
    • Can't do this in my edit_activity? And then I can’t refer to this class, for example, to the toolbar - Mr Klonwar