Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:16:12+00:00 2026-06-18T07:16:12+00:00

I have this main activity public class MainActivity extends FragmentActivity { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager

  • 0

I have this main activity

public class MainActivity extends FragmentActivity {

SectionsPagerAdapter mSectionsPagerAdapter;


ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.activity_main, menu);  
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
        case R.id.menu_settings4:
            mainactivity();
            return true;
        case R.id.menu_settings1:
            ipallilos();
            return true;
        case R.id.menu_settings2:
            rithmisi();
            return true;
        case R.id.menu_settings3:
            sxetika();
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }

}

private void mainactivity() {

    Toast.makeText(MainActivity.this, "Επιστροφή στην Αρχική Σελίδα", 
            Toast.LENGTH_SHORT).show();
}
private void rithmisi() {
    setContentView(R.layout.rithmisis);
    Toast.makeText(MainActivity.this, "Loading Settings", 
            Toast.LENGTH_SHORT).show();
}

private void ipallilos() {
    setContentView(R.layout.ipallilos);
    Toast.makeText(MainActivity.this, "Loading Staff", 
            Toast.LENGTH_SHORT).show();
}

private void sxetika() {
    //anoigma menou efarmogis
    setContentView(R.layout.sxetikame);
    Toast.makeText(MainActivity.this, "Loading about Software", 
            Toast.LENGTH_SHORT).show();


}

 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event)  {
     if ((keyCode == KeyEvent.KEYCODE_BACK)) {
         //moveTaskToBack(true);
         super.onBackPressed();
         return true;
     }

     return super.onKeyDown(keyCode, event);
 }




public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        // getItem is called to instantiate the fragment for the given page.
        // Return a DummySectionFragment (defined as a static inner class
        // below) with the page number as its lone argument.
        Fragment fragment = new DummySectionFragment();
        Bundle args = new Bundle();
        args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getCount() {
        // Show 3 total pages.
        return 2;
    }


    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return getString(R.string.title_section1).toUpperCase();
           // case 1:
              //  return getString(R.string.title_section2).toUpperCase();
            case 1:
                return getString(R.string.title_section3).toUpperCase();
        }
        return null;
    }
}


public static class DummySectionFragment extends Fragment {
    public DummySectionFragment() {
    }
    public static final String ARG_SECTION_NUMBER = "section_number";



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        Bundle args = getArguments();
        switch (args.getInt(ARG_SECTION_NUMBER)){

        case 1: 
            return inflater.inflate(R.layout.paraggeleialayout, container, false);


        case 2:
             return inflater.inflate(R.layout.trapezia, container, false);

    }

        return getView();

}





    }
}

I have at .paraggeleialayout some buttons.
I have try to add setOnClickListener to my button to open an other class but it does not
work. Here is my paraggeleia class.

public class paraggeleia extends Activity {

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
           setContentView(R.layout.paraggeleialayout);
              TextView text = (TextView) findViewById(R.id.TextView1);
                 Button bTutorial = (Button) findViewById(R.id.button51);
                text.setText(R.string.paraggeleia);
           bTutorial.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v){
             finish();
            }
        });
    }





    @Override
     public boolean onKeyDown(int keyCode, KeyEvent event)  {
         if ((keyCode == KeyEvent.KEYCODE_BACK)) {
             super.onBackPressed();
             return true;
         }

         return super.onKeyDown(keyCode, event);
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:16:13+00:00Added an answer on June 18, 2026 at 7:16 am

    Alright, I think this is clearer now, so you want your ViewPager layout to launch the next Activity. You may want to do something like this:

    case 1: 
           View v = inflater.inflate(R.layout.paraggeleialayout, container, false);
           Button bTutorial = (Button) v.findViewById(R.id.button51);
               bTutorial.setOnClickListener(new View.OnClickListener() {
               public void onClick(View v){
               getActivity().startActivity(new Intent (getActivity(), paraggeleia.class));
                }
            });
    return v;
    

    However your paraggeleia.class as it stands contains the same layout (R.layout.paraggeleialayout) as the Fragment, so consider changing that Activity’s layout to something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this structure: 1) main activity: public class mainActivity extends Activity { @Override
I have this code public class MainActivity extends Activity { private static final int
I have a Thread nested in the main activity: public class MainActivity extends Activity
I have this Service class: public class BluetoothService extends Service { private static Activity
I have a MainActivity (FragmentActivity) that has a FragmentTabHost. public class FragmentTabs extends FragmentActivity
I have a design of activities like this I have one main activity and
I have a lot of buttons on main activity. Each button run this same
I have this situation where i have to start an activity from my mainActivity.
I have an activity ( MainActivity.java ) in which content view is like this
I have this declared on my main class: [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@atlas.plist]; CCSpriteBatchNode *batchNode =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.