Note that there are some explanatory texts on larger screens.

plurals
  1. POif Statement only returns last
    text
    copied!<p>In my app I need to be able to find out which key "page" has data on it what I've done with help is create this</p> <pre><code>Bundle p = mWizardModel.findByKey("Surf:Price").getData(); if ( p != null ) { p = mWizardModel.findByKey("Skate:Price").getData(); } if ( p != null ) { p = mWizardModel.findByKey("Snow:Price").getData(); } String price = p.getString(Page.SIMPLE_DATA_KEY); </code></pre> <p>however what happens is this will only return the last if statement in this case ("Snow:Price")</p> <p>How would I go about fixing this issue. I've tried LOTS of different ways already.</p> <p>The if-statement is placed in an onClick where I'm sending the strings to another activity where I'l put them in my database</p> <pre><code>mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPager.getCurrentItem() == mCurrentPageSequence.size()) { Bundle t = mWizardModel.findByKey("Surf:Post Title").getData(); if ( t != null ) { t = mWizardModel.findByKey("Snow:Post Title").getData(); } if ( t != null ) { t = mWizardModel.findByKey("Skate:Post Title").getData(); } String title = t.getString(Page.SIMPLE_DATA_KEY); Bundle p = mWizardModel.findByKey("Surf:Price").getData(); if ( p != null ) { p = mWizardModel.findByKey("Skate:Price").getData(); } if ( p != null ) { p = mWizardModel.findByKey("Snow:Price").getData(); } String price = p.getString(Page.SIMPLE_DATA_KEY); String maincat = mWizardModel.findByKey("Main Category").getData().getString(Page.SIMPLE_DATA_KEY); Intent i = new Intent(getApplicationContext(), PostPhotosActivity.class); i.putExtra("pTITLE", title); i.putExtra("pPRICE", price); i.putExtra("pCATEGORY", maincat); startActivity(i); } else { if (mEditingAfterReview) { mPager.setCurrentItem(mPagerAdapter.getCount() - 1); } else { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } }}); </code></pre> <p>This may be helpful or I might be doing something wrong within this statement completely.</p> <p>Thanks for all your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload