I creat 4 intents of activities(which i add to TabHost) in my main TabActivity. I also have button with onClick method. When this button is clicked i put some extras in intent of activity Rezultati. Now i am trying to call custom method of started activity from this TabActivity to use that extras.
Here is example of creating one of the intents:
public class Prvi extends TabActivity {
public Intent rezultati;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
rezultati = new Intent().setClass(this, Rezultati.class);
spec = tabHost.newTabSpec("rez").setIndicator("Rezultati",
res.getDrawable(R.layout.novice))
.setContent(rezultati);
tabHost.addTab(spec); }
On button click this method is called:
public void isci(View view)
{
EditText iskano = (EditText) findViewById(R.id.iskano);
rezultati.putExtra("Iskano", iskano.getText().toString()); }
Now i Have class Rezultati.class where i would like to call method update:
public class Rezultati extends Activity{
{
public void update(){
String value = getIntent().getExtras().getString("Iskano");
TextView textview = new TextView(this);
textview.setText(value);
setContentView(textview);}
}
I tryed with creating new instance of class Rezultati in function isci(View view) an开发者_如何学God calling function update
Rezultati r=new Rezultati();
r.update();
Unless nothing is in update function when i call r.update() it works, otherwise everytime stops working.
What am i doing wrong?
Pls use the GlobalVariablesApplication to put the Extras in that and wherever u get the
Extras
see this link GlobalVariables
精彩评论