如何从另一种方法中获取价值

时间:2012-12-18 08:22:11

标签: android methods parameters

,例如,

  

public void ShowConventView2(){

     setContentView(R.layout.main);

     String usr = "happy"; }

如何将usr的值传递给ShowConventView3?如果ShowConventView3是

  

public void ShowConventView3(){

     setContentView(R.layout.second);

     TextView txt = (TextView)findViewById(R.id.textView1);

     txt.setText(usr); }

非常感谢。

1 个答案:

答案 0 :(得分:0)

public void ShowConventView2() {
     setContentView(R.layout.main);
     String usr = "happy";
     ShowConventView3(usr);
}

public void ShowConventView3(String text){
     setContentView(R.layout.second);
     TextView txt = (TextView)findViewById(R.id.textView1);
     txt.setText(text); 
}