There is in the project Navigation Drawer, I use fragments in it, in one fragment it shows the contents of the activation in which there are many buttons, I need to make the transition from these buttons to another activation, I don’t know how to go!

MyActivity.java

package tren.SportPit.ru; import android.annotation.TargetApi; import android.app.Activity; import android.app.ActivityManager; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.support.v4.widget.DrawerLayout; import android.widget.ArrayAdapter; import android.widget.TextView; public class MyActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks { /** * Fragment managing the behaviors, interactions and presentation of the navigation drawer. */ private NavigationDrawerFragment mNavigationDrawerFragment; /** * Used to store the last screen title. For use in { @link #restoreActionBar()}. */ private CharSequence mTitle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments android.app.FragmentManager fragmentManager = getFragmentManager(); android.app.Fragment fragment = null; switch (position){ case 0: fragment = new Upraznenia(); break; case 1: fragment = new Eat(); break; case 2: fragment = new Programmy(); break; } fragmentManager.beginTransaction() .replace(R.id.container, fragment) .commit(); } public void onSectionAttached(int number) { switch (number) { case 1: mTitle = getString(R.string.title_section1); break; case 2: mTitle = getString(R.string.title_section2); break; case 3: mTitle = getString(R.string.title_section3); break; } } public void restoreActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle); } @Override public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.my, menu); restoreActionBar(); return true; } return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } public PlaceholderFragment() { } @Override public void onAttach(Activity activity) { super.onAttach(activity); ((MyActivity) activity).onSectionAttached( getArguments().getInt(ARG_SECTION_NUMBER)); } } } 

Upraznenia.java

 package tren.SportPit.ru; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Upraznenia extends Fragment{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.lay_upr, container, false); return rootView; } } 
  • 1. Why did you dump all the code you found here? 2. For you there is no one who is not going to do anything. @katso answered you how to run activation. 3. Format your code normally. My blood begins to flow from my eyes when I look at all this abundance of colors and fonts. 4. If you want to do "very urgent" and "instead of you," contact the freelance exchange. They will do it quickly and inexpensively. 5. Do you really write all the code in one line? - Vladyslav Matviienko
  • No, this is when I put it in here, everything was formatted, but I’m telling me that I still have a kettle, and so far I’m just learning to do everything. I didn’t seem to write to do everything for me, I can’t figure it out, you wrote me a line of code, for you, a knowledgeable person, she probably answered my question, but for me it’s a line of code that I’m only half understand. Wasn this resource created only for "prosharennyh hackerov"? On the moym here, a newbie and the same Hacker can ask a question. And Katso thank you so much, the only ones treated with understanding. - alex11
  • @ alex11, this resource is created for new questions that have not been asked anywhere else. If this is done for you, then ask the same who did and correct. If you do not understand how to do this, then you will not begin to understand if they do it for you. If you want to understand - learn from the very beginning on lessons. If you do not want to - pay someone to do what they would do for you. - Vladyslav Matviienko
  • one
    @Expert ♦♦ again, I suggest you stop doing garbage. Who asked you to turn my comment in response? Or do you think that you know better that I wanted to leave a response, or a comment ?? - Vladyslav Matviienko
  • I learned from the lessons "StartAndroid", but there is no such thing, I asked a completely adequate question, but then they came up that discourages the desire to ask questions. And if there are lessons on this topic, they are in English or Spanish, which makes it impossible for me to fully understand this topic. And thanks to the one who edited for me. - alex11

1 answer 1

 startActivity(new Intent(getActivity(), NewActivity.class)); 
  • It is possible in more detail, I just still have a kettle at all, but I don’t have enough lessons for Andrew, I have to take it apart for a very long time, I hope you will help - alex11
  • @ alex11 is not enough lessons ?? Are you kidding me?? there are so many of them that there is not enough human life to review everything! - Vladyslav Matviienko
  • @ alex11, call this method in the snippet, NewActivity is the name of the new activation, [read more about launching the activation] [1] [1]: startandroid.ru/ru/uroki/vse-uroki-spiskom/… - katso
  • @ alex11, in the @Override public void onActivityCreated (Bundle savedInstanceState) {super.onActivityCreated (savedInstanceState); Button button = getView (). FindViewById (R.id.button); } - katso
  • private Button btnSheya; @Override public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View view = null; view = inflater.inflate (R.layout.lay_upr, container, false); btnSheya = (Button) view.findViewById (R.id.sheya); btnSheya.setOnClickListener (this); return view; } @Override public void onClick (View v) {switch (v.getId ()) {case R.id.sheya: startActivity (new Intent (getActivity (), lay_sheya.class)); break; } - alex11