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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:04:43+00:00 2026-06-07T08:04:43+00:00

This is what I am doing: In a ListActivity (NOT a ListFragment): Intent i

  • 0

This is what I am doing:

In a ListActivity (NOT a ListFragment):

Intent i = new Intent(getApplicationContext(), MyFragmentActivity.class);
i.putExtra("name", items.get(arg2));
startActivity(i);

Then in MyFragmentActivity (using support library):

  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_layout);

    this.initialiseTabHost(savedInstanceState);
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));

        RateFrag rate = new RateFrag();
        rate.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, rate).commit();

    }

    this.intialiseViewPager();
}

Then in Rate Fragment:

 public class RateFrag extends Fragment {

  public static RateFrag newInstance(CharSequence name) {
    RateFrag f = new RateFrag();
    Bundle args = new Bundle();
    args.putCharSequence("name", name);
    f.setArguments(args);
    return f;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Item = getArguments().getString("name");

}



@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    title = (TextView) getActivity().findViewById(R.id.tvRateItem);
    ratingsBar = (RatingBar) getActivity().findViewById(R.id.theRatingBar);

    title.setText(Item);

}

 // stuff!

 }

So I am essentially trying to pass an “extra” from the original ListActivity into a textview in the Fragment in the last line of code above.

This is what I get in LogCat when I click on the ListItem:

07-09 19:12:39.998: E/AndroidRuntime(1788): FATAL EXCEPTION: main
07-09 19:12:39.998: E/AndroidRuntime(1788): java.lang.NullPointerException
07-09 19:12:39.998: E/AndroidRuntime(1788):     at com.---.---.RateFrag.onCreate(RateFrag.java:61)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:834)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.app.FragmentManagerImpl.performPendingDeferredStart(FragmentManager.java:768)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.app.Fragment.setUserVisibleHint(Fragment.java:746)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.app.FragmentPagerAdapter.setPrimaryItem(FragmentPagerAdapter.java:128)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.view.ViewPager.populate(ViewPager.java:802)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1016)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.View.measure(View.java:15172)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.Choreographer.doCallbacks(Choreographer.java:555)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.Choreographer.doFrame(Choreographer.java:525)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.os.Handler.handleCallback(Handler.java:615)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.os.Looper.loop(Looper.java:137)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at android.app.ActivityThread.main(ActivityThread.java:4745)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at java.lang.reflect.Method.invokeNative(Native Method)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at java.lang.reflect.Method.invoke(Method.java:511)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-09 19:12:39.998: E/AndroidRuntime(1788):     at dalvik.system.NativeStart.main(Native Method)

Converting my app to use Fragments is driving me nuts! Admittedly, the final product is much better looking, its complexity is extremely frustrating. Can someone point me in the right direction to see where I am failing?

EDIT: Here is my Tab Layout:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >

            <TabWidget
                android:id="@android:id/tabs"
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="0"/>

            <FrameLayout
                android:id="@+android:id/content"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"/>
        </LinearLayout>
    </TabHost>
</LinearLayout>
  • 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-07T08:04:45+00:00Added an answer on June 7, 2026 at 8:04 am

    The problem is that you are attempting to instantiate two Fragment‘s here… one is being inflated from fragment_layout.xml, and the other is being instantiated programatically and placed on screen with a FragmentTransaction.

    Pick only one of these two means of instantiating your Fragment… whichever option best suits the situation (I can’t tell from the minimal code you have provided).

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

Sidebar

Related Questions

I'm doing this with a very simple class, just to learn, but I'm not
I am doing this currently, class Page { // variable to hold DBC class
I am doing this: // Member variable List<String> items = null; // in onCreate
I am not sure I am doing this right, with my limited knowledge of
I have an Activity which I start like this: public class MyProblemsActivity extends ListActivity
I believe I'm doing this correctly, in my activity class I'm calling execute the
I am new so forgive my primitive question, I am really not getting this.
Im doing this project where i need to download files through a webservice (images,
This is my first time doing this sort of project so apologies if the
I'm doing this interface where I have a lot of buttons that are just

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.