Android own Activity start function
i've tried to start an activity with my own function, but it doesn't work (think its a logic fault ;) )
Please have a look at:
Intent adder = new Add().execute(this, Add.class, "Test:","Add the test");
startActivity(adder);
This is the Activity which i want to start:
public class Add extends Activity {
public Intent execute(Context context, Class<?> cls, String addText, String buttonText) {
TextView addStr = (TextView) findViewById(R.id.addtext);
开发者_JAVA百科 addStr.setText(addText);
Button addBtn = (Button) findViewById(R.id.addbtn);
addBtn.setText(buttonText);
return new Intent(context, cls);
}
}
What's wrong?
You should take a look at this Android developer guide, which talks about Activity and Intent. I think you will see that they are used in a completely different way than you are trying to use them.
精彩评论