Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with TextView in android
    text
    copied!<p>I am having an issue with my TextView. I have a PlayScreenActivity that displays supplies info. on the top of screen. then I go to the store screen and buy supplies. when I come back all others change but 1 and it will display the new value if I turn my phone and orientation changes, thats the only way I can see the added supplies purchased. Anyone have an Idea why this is happening?</p> <p>I set screen orientation to portrait to see if it will work if it can't switch but doesnt fix.</p> <p>EDIT</p> <p>Here is a copy of my Activity Code:</p> <p>public class PlayscreenActivity extends Activity { Data data_;</p> <pre><code>/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ((TextView)findViewById(R.id.lemonsLeftText)).setText( "Lemons: " ); ((TextView)findViewById(R.id.sugarLeftText)).setText( "Sugar: " ); ((TextView)findViewById(R.id.iceLeftText)).setText( "Ice: " ); ((TextView)findViewById(R.id.cupsLeftText)).setText( "Cups: " ); ((Button)findViewById(R.id.btnshop)).setOnClickListener( new SupplyShopListener()); } private class SupplyShopListener implements OnClickListener{ public void onClick(View v){ Intent i = new Intent(v.getContext(), SupplyShopActivity.class); startActivity(i); //refreshDisplay(); } </code></pre> <p>}</p> <pre><code>@Override public void onResume(){ super.onResume(); data_ = getData(); refreshDisplay(); } @Override public void onPause(){ super.onPause(); saveData(); refreshDisplay(); } @Override public void onConfigurationChanged(Configuration newConfig){ super.onConfigurationChanged(newConfig); //refreshDisplay(); } private Data getData() { GameData player_data = new GameData(this); player_data.open(); Data game_state = new Data(player_data.getGameString()); player_data.close(); return game_state; } private void saveData() { GameData player_data = new GameData(this); player_data.open(); player_data.setGameString(data_.SerializeGame()); player_data.close(); } private void refreshDisplay() { NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); String totalCash = nf.format(data_.cash_); ((TextView)findViewById(R.id.lemonsLeftText)).setText( "Lemons: " + Integer.toString(data_.lemons_) ); ((TextView)findViewById(R.id.sugarLeftText)).setText( "Sugar: " + Integer.toString(data_.sugar_) ); ((TextView)findViewById(R.id.iceLeftText)).setText( "Ice: " + Integer.toString(data_.ice_) ); ((TextView)findViewById(R.id.cupsLeftText)).setText( "Cups: " + Integer.toString(data_.cups_) ); ((TextView)findViewById(R.id.totalCashText)).setText( "Cash : " + (totalCash) ); } </code></pre> <p>}</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