I have problem in my code in the commented lines:
bouton.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
url=edit.getText().toString();
System.out.println(url);
// this line and
Intent Activite=new Intent(this, Main1.class);
Activite.putExtra("param", url);
/// this line
this.startActivityForResult(Activite, 1000);
}
});
Can you help me to correct my code
-
1What problem? What error? What is Main1.class, does it exist? What is edit? Give us more to go on, we can't help you this way.Theun Arbeider– Theun Arbeider2011年03月28日 10:30:19 +00:00Commented Mar 28, 2011 at 10:30
2 Answers 2
either remove this from the line where you are starting the next activity.
OR
use:
ClassName.this.startActivityForResult(Activite, 1000);
Basically when you are saying this : this.startActivityForResult(Activite, 1000); "this" is corresponding to the context of OnClickListener and not of the Activity you are in. As you already know that startActivityForResult is a method on Activity class and not of android.view.View.OnClickListener class.
Hope this helps!!
Comments
In addition to mudit, replace
Intent Activite=new Intent(this, Main1.class);
with Intent Activite=new Intent(ActivityClassName.this, Main1.class);
But Levisaxos was right, you could give us more info, at least your stack trace