Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default Re: Set spinner value in fragment

    You need to stick some logging in there and ensure that things like accountNo actually have the value you expect.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

    Default Re: Set spinner value in fragment

    I am only interested for this value not to be null ...

  4. #4
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

    Default Re: Set spinner value in fragment

    It is odd because when I try sty like this:
    Java Code:
    @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            super.onCreateView(inflater, container, savedInstanceState);
            View view = inflater.inflate(R.fragment, container, false);
            Bundle args = getArguments();
            if (args != null && args.containsKey("accountNumber")){
                accountNumber = args.getString("accountNumber").toString(); //accountNumber not null 
                Toast toast = Toast.makeText(getActivity(), accountNumber, Toast.LENGTH_SHORT);
                toast.show();
            initTimePeriodSpinner(view, accountNumber);
    }
            getLoaderManager().initLoader(ACCOUNT_LOADER_ID, getArguments(), this);
    
            return view;
        }
    the toast is shown but the value of the spinner is not changed.
    and whn i try like this:
    Java Code:
    @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            super.onCreateView(inflater, container, savedInstanceState);
            View view = inflater.inflate(R.fragment, container, false);
            Bundle args = getArguments();
            if (args != null && args.containsKey("accountNumber")){
                accountNumber = args.getString("accountNumber").toString(); //accountNumber not null 
                initTimePeriodSpinner(view, accountNumber);
    }
            getLoaderManager().initLoader(ACCOUNT_LOADER_ID, getArguments(), this);
    
            return view;
        }
    the if is just skipped

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default Re: Set spinner value in fragment

    Use debug logging to determine exactly what is happening.
    Anything else is guesswork on your part.

    Once you have some decent debugging in there then you can tell us exactly what is going on in your code.

    And that debugging should be in both the onCreateView method as well as the initTimePeriodSpinner method.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

    Default Re: Set spinner value in fragment

    I did the debugging setting a breakpoint in the initTimePeriodSpinner method and in accountNumber = args.getString("accountNumber").toString()
    inside the onCreateView method. It happens that the debugger enters first in the initTimePeriodSpinner method ...
    Last edited by blertadhimitri; 08-21-2014 at 10:47 AM.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default Re: Set spinner value in fragment

    No, you don't understand.
    Add debug logging in there.
    Something you can then copy and paste here to show exactly what is happening.
    The order code is executed, and the values passed around.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    Join Date
    Jan 2013
    Posts
    69
    Rep Power
    0

    Default Re: Set spinner value in fragment

    Image 1: breakpoint in accountNumber, value of spinner inside if statement
    Set spinner value in fragment-screen-shot-2014-08-21-10.13.35.png

    Image 2: breakpoint in accountNumber, value of spinner outside if statement
    Set spinner value in fragment-screen-shot-2014-08-21-10.14.07.png

    Image 3: breakpoint in initTimePeriodSpinner method. Value of accountNumber null
    Set spinner value in fragment-screen-shot-2014-08-21-10.17.25.png
    Last edited by blertadhimitri; 08-21-2014 at 11:21 AM.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default Re: Set spinner value in fragment

    ...sigh...
    I'm not asking you to debug.
    I'm asking you to LOG.

    That ensures the code you are looking at in debug is the actual code running.
    It also gives you (and us) a record of the actual flow.

    If you can't be arsed to do that then I give up.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 03-12-2014, 08:26 PM
  2. Unwanted image fragment
    By polmos in forum New To Java
    Replies: 6
    Last Post: 09-12-2012, 04:00 PM
  3. Spinner does not get updated !
    By DennisM in forum NetBeans
    Replies: 0
    Last Post: 02-28-2012, 07:59 AM
  4. Creating and initializing a SWT spinner widget
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 05:50 PM
  5. How to use SWT Spinner
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 05:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •