我有一个名为EventListSmallView
和FollowerFollowingView
的视图,它扩展了RelativeLayout,并在我的活动中动态创建。
问题是:
如果我为FollowerFollowingView
设置onClickListener它可以正常工作,但是当我尝试使用EventListSmallView
时它不起作用。
这就是我如何设置每一个: - EventListSmallView
for (Event event : eventsGo){
final Event e = event;
EventListSmallView eventListSmallView = EventListSmallView_.build(this);
eventListSmallView.bind(event);
eventListSmallView.setClickable(true);
eventListSmallView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String json = new Gson().toJson(e);
EventDetailActivity_.intent(ProfileActivity.this)
.extra("json", json).start();
// Intent it = new Intent(ProfileActivity.this, EventDetailActivity_.class);
// it.putExtra("json", json);
// startActivity(it);
}
});
dynamicGo.addView(eventListSmallView);
}
和FollowerFollowingView:
FollowerFollowingView itemView = FollowerFollowingView_.build(this);
itemView.bind(p);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String json = new Gson().toJson(profile);
if (profile.getId() == Config.getMyID(getApplicationContext())){
ProfileActivity_.intent(EventDetailActivity.this)
.extra("serialized_profile", json).extra("is_user",true).start();
}else {
ProfileActivity_.intent(EventDetailActivity.this)
.extra("serialized_profile", json)
.start();
}
}
});
whoGoing.addView(itemView);