private int pos = position;
@Override
public void onClick(View v) {
Toast.makeText(context, "Click-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
iBean = (InboxBean)result.get(position);
ConstantData.inbox_subject = iBean.subject;
ConstantData.inbox_body = iBean.body;
ConstantData.inbox_postDate = iBean.postdate;
startActivity(new Intent(InboxActivity.this,InboxDetailActivity.class));//getting error at startActivity
}
});
I am getting the following error at startActivity line:
"Cannot make a static reference to the non-static method startActivity(Intent) from the type Activity"
Please help.
I assume you have this in the inner static class of your activity. Don't do that. OnClickListeners should exist in the context of the particular instance of activity.
To make static reference to non static methods, you need to call them by using the context of the activity or application.
This is also true when you need to call activity from non activity class.
The following type of code can be used
Intent cc=new Intent(yourcontext,Yourpackagename.ClassName.class);
yourcontext.startActivity(cc);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With