error in my code
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
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!!
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
精彩评论