1. Download our Official Android App: Forums for Android!

Apps textview save and reuse

Discussion in 'Android Development' started by phoenix2025, Jun 3, 2011.

  1. phoenix2025

    phoenix2025 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Jun 3, 2011

    Jun 3, 2011
    2
    0
    5
    Hello

    I come to you because I have one problem and all my tentative doesn't solve my problem.

    I would like to save the value of one textview inside on variable, and reuse this variable to put inside one other.

    For the moment my code look like that :
    Code (Text):
    1.  
    2. public class mainresult extends Activity {
    3.  
    4.     TextView h2,h1;
    5.    
    6.    
    7.         public void onCreate(Bundle savedInstanceState) {
    8.            
    9.             super.onCreate(savedInstanceState);
    10.             setContentView(R.layout.result);
    11.            
    12.                 h1=(TextView)findViewById(R.id.R1);
    13.                 h2=(TextView)findViewById(R.id.R2);
    14.            
    15.             String R=h2.getText().toString(); // this is the action with problem
    16.             if (R==null||R=="0"){
    17.             h1.setText("toto");
    18.             }
    19.             else{
    20.                 h1.setText(R);
    21.             }
    22.         }
    23. }
    24.  
    And one thing that I would after it's to save this variable (R) into the cache, for reuse after that the program was closed.

    Thanks for your help
     

    Advertisement

  2. phoenix2025

    phoenix2025 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Jun 3, 2011

    Jun 3, 2011
    2
    0
    5
    voici le logcat
     

Share This Page

Loading...