我有水平视图项目(图像,名称在图像下方,以及两个按钮(是,否),名称下方)
我想在类中点击事件是没有按钮..当适用于项目点击时按钮上的CLick On按钮时不适用。按钮CLick未执行
我试过这样请告诉我我做错了什么
我试过像下面这样
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
Toast.makeText(getActivity(), "ListView clicked" + id, Toast.LENGTH_SHORT).show();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v.getId() == R.id.yes) {
Toast.makeText(getActivity(), "Yes clicked", Toast.LENGTH_SHORT).show();
} else if (v.getId() == R.id.no_btn) {
Toast.makeText(getActivity(), "No clicked", Toast.LENGTH_SHORT).show();
}
}
适配器中的
setClickListeners(holder.btnyes);
setClickListeners(holder.btnno);
//Button click Yes
/* holder.btnyes.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
((HorizontalListView) parent).performItemClick(v, position, 0);
UserProfile u=new UserProfile();
data.remove(position);
notifyDataSetChanged();
// new adduser().execute();
}
});*/
holder.btnno.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
((HorizontalListView) parent).performItemClick(v, position, 0);
/*UserProfile u=new UserProfile();
data.remove(position);
notifyDataSetChanged();*/
// new adduser().execute();
}
});
答案 0 :(得分:0)
取代
setClickListeners(holder.btnyes);
试试这个
setOnItemClickListner();