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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:19:40+00:00 2026-06-09T01:19:40+00:00

I want put a Bundle in a Fragment. This bundle must exist in the

  • 0

I want put a Bundle in a Fragment. This bundle must exist in the onCreate Method.
But I’m getting a null pointer exception.

The code part in the Activity

Bundle bundl = new Bundle();
String headlines[]  = {"sdfsdf","sdfsd","fgfg","sdffsd"};
bundl.putStringArray("123", headlines);
bundl.putStringArray("1253", headlines);
HeadlinesFragment firstFragment = new HeadlinesFragment();
firstFragment.setArguments(bundl); 

the onCreate method

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

    // Here is the null pointer
    headlines =getArguments().getStringArray("123");

    int layout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.layout.simple_list_item_activated_1
            : android.R.layout.simple_list_item_1;
    inserts = new ArrayAdapter<String>(getActivity(), layout, headlines);

    setListAdapter(inserts);
}

Layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment android:name="com.de.ordix.HeadlinesFragment"
          android:id="@+id/headlines_fragment"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="match_parent" />

<fragment android:name="com.de.ordix.ArticleFragment"
          android:id="@+id/abwesend_fragment"
          android:layout_weight="2"
          android:layout_width="0dp"
          android:layout_height="match_parent" />

here the error log

E/AndroidRuntime(25007): FATAL EXCEPTION: main
E/AndroidRuntime(25007): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.de.xx/com.de.xx.MainActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
E/AndroidRuntime(25007): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime(25007): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime(25007): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime(25007): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime(25007): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(25007): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(25007): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(25007): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(25007): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(25007): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(25007): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(25007): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(25007): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
E/AndroidRuntime(25007): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
E/AndroidRuntime(25007): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime(25007): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime(25007): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime(25007): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime(25007): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/AndroidRuntime(25007): at android.app.Activity.setContentView(Activity.java:1835)
E/AndroidRuntime(25007): at com.de.xx.MainActivity.onCreate(MainActivity.java:37)
E/AndroidRuntime(25007): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(25007): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(25007): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime(25007): ... 11 more
E/AndroidRuntime(25007): Caused by: java.lang.NullPointerException
E/AndroidRuntime(25007): at com.de.xx.HeadlinesFragment.onCreate(HeadlinesFragment.java:39)
E/AndroidRuntime(25007): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:835)
E/AndroidRuntime(25007): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
E/AndroidRuntime(25007): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1160)
E/AndroidRuntime(25007): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
E/AndroidRuntime(25007): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
E/AndroidRuntime(25007): ... 21 more
  • 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-09T01:19:41+00:00Added an answer on June 9, 2026 at 1:19 am

    Declare one class and static variable

    public class global {
      public static String headlines[] ;
    }
    

    Now Your Code

    global.headlines =  {"sdfsdf","sdfsd","fgfg","sdffsd"};
    

    And
    When you want to use

    inserts = new ArrayAdapter<String>(getActivity(), layout, global.headlines);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to open Android Contacts @Override public void onCreate(Bundle savedInstanceState)
I want to display pdf file in webview. I try using this code it
i want to put some string of a bundle into an custom dialog. So
Here is my code. I want to put a back button on the opening
I put a button on view and want to call this view from another
I have this code public class MyFragment extends SherlockFragment { public static Fragment newInstance(Context
I want put a button on android edittextpreference. I create a custom editextpreference: public
I've projected an Intranet Ajax application and I want put it in a full
hey, hi i want put limit on object creation means a class can have
I want to put two side by side on another (I have three )

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.