2
我在我的主TabActivity中創建4個活動(我添加到TabHost)的意圖。我也有onClick方法的按鈕。當點擊這個按鈕時,我會爲了Rezultati的活動而增加一些額外的功能。現在我試圖從這個TabActivity中調用啓動活動的自定義方法來使用這些額外功能。在Button中點擊TabActivity調用啓動活動中的自定義方法點擊
這裏是例如創建意圖之一:
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); }
在點擊按鈕調用此方法:
public void isci(View view)
{
EditText iskano = (EditText) findViewById(R.id.iskano);
rezultati.putExtra("Iskano", iskano.getText().toString()); }
現在我有類Rezultati.class在這裏我想調用方法更新:
public class Rezultati extends Activity{
{
public void update(){
String value = getIntent().getExtras().getString("Iskano");
TextView textview = new TextView(this);
textview.setText(value);
setContentView(textview);}
}
我嘗試在函數isci中創建類Rezultati的新實例(查看視圖)和調用功能更新
Rezultati r=new Rezultati();
r.update();
除非沒有在更新功能時,我打電話r.update()它的工作原理,否則每次停止工作。
我在做什麼錯了?
你找到關於這樣的任何解決方案,我也面臨着同樣的問題? – CoDe 2012-07-09 01:11:55