1

I have followed the tutorial for android tab host and been able to run on emulator. Now what I want to do is just implement a text box and button in one tabview. As soon as user enter in text box and press button the value entered in text box shouls pass to second tab and I can use that value for further calculations.

Please guide me how to do this? Thanks, Alok.

Shoe
  • 74,840
  • 36
  • 166
  • 272
maddy
  • 4,001
  • 8
  • 42
  • 65

1 Answers1

5

I think what you should to do is to declare a global variable:

class foobarApp extends Application {

  private String txtValue;

  public String getTxtValue(){
    return txtValue;
  }
  public void setTxtValue(String aString){
    txtValue= aString;
  }
}

So, when the user presses the button:

foobarApp myApp = ((foobarApp)getApplicationContext());
setTxtValue(myTextEdit.getText());

And then, when the second tab loaded, you can get your value by doing this:

foobarApp myApp = ((foobarApp)getApplicationContext());
theOtherEditText.setText(myApp.getTxtValue());
Zakaria
  • 14,892
  • 22
  • 84
  • 125