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

The Archive Base Latest Questions

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

For some reason, the values from the gridView aren’t being saved from the Bundle.

  • 0

For some reason, the values from the gridView aren’t being saved from the Bundle. Nothing is being outputted to the logcat either. Am I getting the values from the gridview properly? It is full of edit texts, so it should be getting the values from there

public class RedScorerFragment extends SherlockFragment {

LayoutInflater infl;
GridView mGrid;

int R1C1, R1C2, R1C3;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    infl = inflater;
    View mView = inflater.inflate(R.layout.fragment_score_red, container, false);
    mGrid = (GridView) mView.findViewById(R.id.gridViewRed);


    if(savedInstanceState != null)
    {
        R1C1 = savedInstanceState.getInt("R1C1");
        R1C2 = savedInstanceState.getInt("R1C2");
        R1C3 = savedInstanceState.getInt("R1C3");

        Log.d("savedd R1C1 ", String.valueOf(R1C1));
        Log.d("savedd R1C2 ", String.valueOf(R1C2));
        Log.d("savedd R1C3 ", String.valueOf(R1C3));
    }


    mGrid.setAdapter(new ImageAdapter(getActivity()));
    return mView;
}

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

    if(savedInstanceState != null)
    {
        R1C1 = savedInstanceState.getInt("R1C1", 0);
        R1C2 = savedInstanceState.getInt("R1C2", 0);
        R1C3 = savedInstanceState.getInt("R1C3", 0);

        Log.v("saved R1C1 ", String.valueOf(R1C1));
        Log.v("saved R1C2 ", String.valueOf(R1C2));
        Log.v("saved R1C3 ", String.valueOf(R1C3));
    }
}

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

    //for(int i=0;i<mGrid.getChildCount(); i++)
    Log.e("Saving", mGrid.getChildAt(0).toString());
    Log.e("Saving", mGrid.getChildAt(1).toString());
    Log.e("Saving", mGrid.getChildAt(2).toString());
    savedInstanceState.putInt("R1C1", Integer.valueOf(mGrid.getItemAtPosition(0).toString()) );
    savedInstanceState.putInt("R1C2", Integer.valueOf(mGrid.getItemAtPosition(1).toString()) );
    savedInstanceState.putInt("R1C3", Integer.valueOf(mGrid.getItemAtPosition(2).toString()) );

}

}

The logcat

12-22 23:58:38.736: E/AndroidRuntime(2481): FATAL EXCEPTION: main
12-22 23:58:38.736: E/AndroidRuntime(2481): java.lang.RuntimeException: Unable to pause activity {org.say.upscorer/org.say.upscorer.MainActivity}: java.lang.NullPointerException
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3348)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3305)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3288)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.access$2500(ActivityThread.java:125)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.os.Looper.loop(Looper.java:123)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at java.lang.reflect.Method.invokeNative(Native Method)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at java.lang.reflect.Method.invoke(Method.java:521)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at dalvik.system.NativeStart.main(Native Method)
12-22 23:58:38.736: E/AndroidRuntime(2481): Caused by: java.lang.NullPointerException
12-22 23:58:38.736: E/AndroidRuntime(2481):     at org.saywatt.scoring.RedScorerFragment.onSaveInstanceState(RedScorerFragment.java:91)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:1607)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1587)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1655)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:527)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.Activity.performSaveInstanceState(Activity.java:1036)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1180)
12-22 23:58:38.736: E/AndroidRuntime(2481):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3330)
12-22 23:58:38.736: E/AndroidRuntime(2481):     ... 12 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-16T07:14:12+00:00Added an answer on June 16, 2026 at 7:14 am

    The Bundle::get family of functions take a tag or id as a parameter. That’s how they know what exactly are you asking for. I.e.,

    // get a String with id "R1C1", note the quotes
    R1C1 = savedInstanceState.getString("R1C1");
    

    The way you are calling them, which works just by chance since you are dealing with Strings, is actually asking for a String with an id of whatever R1C1 contains at that time.

    But you are putting ints on the bundle and expect to extract Strings, that’s a plain and simple error.

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

Sidebar

Related Questions

I'm using PDO and MySQL, for some reason when getting values from the database
For some reason, my spec isn't passing. It appears that @categories isn't getting to
For some reason I am getting an error this error: mysql_fetch_array() expects parameter 1
Having trouble getting my POST arrays to show all checkbox values from my form.
Hi I am using the following code to read some values from lines containing
I have a gridview that I databind dynamically in my codebehind. For some reason,
I am using the Spring NamedParameterJdbcTemplate to fetch some values from a table. For
I am having some trouble sending values from one page to another using the
I'm having a hard time getting the values from a small multiple choice questionnaire
the following code for some bizarre reason gives me a value for each row

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.