private void readShops() {
RetailerAdapter retailersAdapter = new RetailerAdapter(
getApplicationContext(), retailers);
final ListView listViewRetailers = (ListView) findViewById(R.id.listViewRetailers);
listViewRetailers.setAdapter(retailersAdapter);
listViewRetailers
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parentView,
View childView, int position, long id) {
Intent intentNews = new Intent(this, RetailerActivity.class);
intentNews.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intentNews);
}
});
}
It bugs because of Intent(this, RetailerActivity.class);
Intent(null, RetailerActivity.class); fixes it but then the app crashes.
Can anyone help me?
Thanks in advance.
Replace
Intent intentNews = new Intent(this, RetailerActivity.class);
with
Intent intentNews = new Intent(YourActivityName.this, RetailerActivity.class);
在您的Intent中,请使用YourActivityName.this或getApplicationContext();代替它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.