2011-09-07 54 views
0

我试图用我自己的功能开始活动,但它不工作(认为它是一个逻辑错误;))Android的自身活动启动功能

请看看:

Intent adder = new Add().execute(this, Add.class, "Test:","Add the test"); 
     startActivity(adder); 

这是我要开始活动:

public class Add extends Activity { 

public Intent execute(Context context, Class<?> cls, String addText, String buttonText) { 
    TextView addStr = (TextView) findViewById(R.id.addtext); 
    addStr.setText(addText); 
    Button addBtn = (Button) findViewById(R.id.addbtn); 
    addBtn.setText(buttonText); 
    return new Intent(context, cls); 
} 

}

有什么不对?

回答

0

你应该看看this Android developer guide,其中谈到活动和意图。我想你会看到,它们的使用方式与您尝试使用它们完全不同。

+0

您如何看待我在活动中看到的内容?我想为两个动作使用一个活动,所以我必须更改活动中的一些文本。 –