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 9062781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:49:32+00:00 2026-06-16T15:49:32+00:00

I have A fragment in another class and i want to launch it from

  • 0

I have A fragment in another class and i want to launch it from my tab activity (which Google provide directly):

Here’s the part of my FragmentActivity that control fragments, i don’t want the dummy one but the one i created in another class

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.

                    // Here is my fragment
        Fragment fragment = new MyFragment();
        return fragment;
    }

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

    @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 2:
            return getString(R.string.title_section3).toUpperCase();
        }
        return null;
    }
}

And here is my MyFragment :

public class MyFragment extends Fragment{

public Search() {
    // TODO Auto-generated constructor stub
}
public View onCreateView(String name, Context context, AttributeSet attrs) {
    // TODO Auto-generated method stub
    TextView textView = new TextView(context);
    textView.setText("search page");
    return textView;
}
}

But it doesn’t work.

  • 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-16T15:49:33+00:00Added an answer on June 16, 2026 at 3:49 pm

    Okay, the answer is simple :

    public View onCreateView(String name, Context context, AttributeSet attrs) {
    // TODO Auto-generated method stub
    TextView textView = new TextView(context);
    textView.setText("search page");
    return textView;
    }
    

    is not a real method, i don’t even know why Eclipse gave me this when i created the class.

    The real method is :

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        TextView textView = new TextView(context);
        textView.setText("search page");
        return textView;
    }
    

    This is just a problem of parameters.

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

Sidebar

Related Questions

What is the correct way of calling a fragment method from another class? I
I have a fragment class. Here is it below: public class FragmentA extends Fragment
I have an int/string(s) that is passed from one fragment to another. For each
I have a fragment that I need to display on the screen. I want
I have a fragment where I wish to call a method from the FragmentActivity
I have a fragment of html which is contained in a property of a
Lets say you have a fragment of the page which displays the most recent
I have a javascript file that reads another file which may contain javascript fragments
I have a Fragment called MeinProfilFragment . And a MainActivity which handles the ActionBar-Tabs
I have a fragment interface with tabs along the bottom which open different fragments

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.