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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:52:42+00:00 2026-06-06T03:52:42+00:00

So i have an Activity(lets call it A) with a view pager and 3

  • 0

So i have an Activity(lets call it A) with a view pager and 3 fragments, one of these fragments(lets call it fragment A) loads a list. The onclickitem list of this list will trigger a callback to the activity(A) so it launchs a new activity(lets call it B) with a new fragment(B too):

Fragment(A) with list, containing the interface and onclickItemListener():

// Container Activity must implement this interface
public interface onProcessSelectedListener{

    public void onMyProcessSelected(MyProcessDTO process);
}

actualListView.setOnItemClickListener(
                new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view,
                            int position, long id) {

                        IpdmsMobileMenuItemListDTO dto=(IpdmsMobileMenuItemListDTO) parent.getItemAtPosition(position);

                        if(getView().findViewById(R.id.myprocessdetail)!=null)
                            updateProcess((MyProcessDTO) dto.getDto());
                        else{

                            mListener.onMyProcessSelected((MyProcessDTO) dto.getDto());
                        }
                    }
                });

In case the layout doesnt show a specific view it will launch the callback method on the Activity(A) that houses the view pager with this fragment:

@Override
public void onMyProcessSelected(MyProcessDTO process) {

    Intent showContent = new Intent(getApplicationContext(),MyProcessDetail.class);
    showContent.putExtra("Process", process);
    startActivity(showContent);
}

Which will call the new activity(B):

@Override
public void onCreate() {

    this.setTheme(getThemeId());
    super.onCreate(bundle);

    //get extras from bundle
    extras = getIntent().getExtras();
    //requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    setContentView(getLayoutId());

    MyProcessDTO process= (MyProcessDTO) extras.get("Process");

    //get fragment
    MyProcessDetailsFragment contentProcess= (MyProcessDetailsFragment) getSupportFragmentManager()
    .findFragmentById(R.id.view_fragment);

    contentProcess.updateProcess(process);
}

The layout loaded in the Activity(B), contains the fragment tag that points to the Fragment(B) class
The Activity(B) calls the fragment(B) method updateProcess():

public void updateProcess(MyProcessDTO process){

    nrProcTV.setText(process.getNrprocesso());
    tipoTV.setText(process.getVariante());
}

But these textviews are null for some reason. They’re initialized on the onActivityCreated method of the fragment(B).:

@Override
public void initializeFragment(Bundle savedInstanceState) {

    super.initializeFragment(savedInstanceState);

    nrProcTV=   (TextView) getView().findViewById(R.id.nrprocesso_value);
    tipoTV= (TextView) getView().findViewById(R.id.tipoprocesso_value);

}

Why hasnt the method onActivityCreated executed before the call to the updateProcess method??

regards,

.

  • 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-06T03:52:43+00:00Added an answer on June 6, 2026 at 3:52 am

    The textViews are null because you access them before the fragment has gone trough onViewCreated(). You can solve your problem by having the Activity set a field in the Fragment, and let the Fragment use that field to view.setText in its onViewCreated method.

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

Sidebar

Related Questions

in the process of building an app, I have an Activity lets call it
Its possible to retain a Fragment between Activities? Lets say I have Activity A
So, lets say in my main activity, i have an array declared like this,
lets say, i have two tables, one for object records and one for activity
I have a main activity, then i call a new activity intent from this.
I have a non-Activity class (let's call it NonActivity) that needs to post a
I have an activity that lets the user load some data when they press
I have an activity which shows some List entries. When I click on a
Assume I have an Activity which contains two FrameLayouts (let's call them FrameA and
I have an application that have three activities, lets call they A, B and

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.