1. Are you ready for the Galaxy S20? Here is everything we know so far!

textview save and reuse

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

  1. phoenix2025

    phoenix2025 Lurker
    Thread Starter

    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
     


  2. phoenix2025

    phoenix2025 Lurker
    Thread Starter

    voici le logcat
     
Loading...
Similar Threads - textview save reuse
  1. Ronald Scholten
    Replies:
    0
    Views:
    199
  2. Cinemato
    Replies:
    0
    Views:
    432
  3. CitingGazelle
    Replies:
    1
    Views:
    601
  4. UmBottesWillen
    Replies:
    1
    Views:
    403
  5. Greum
    Replies:
    20
    Views:
    654
  6. irajfacebook84
    Replies:
    0
    Views:
    353
  7. Lampros_36
    Replies:
    3
    Views:
    863
  8. Greum
    Replies:
    2
    Views:
    1,759
  9. BobAchgill
    Replies:
    0
    Views:
    461
  10. Mdzh
    Replies:
    3
    Views:
    928

Share This Page

Loading...