0
我有一個ListView,我有我自己定製的ListItem我正在對他們應用動作偵聽器,但他們沒有響應事件。setOnClickListener不工作裏面CustomAdapter擴展ArrayAdapter
private class CustomAdapter extends ArrayAdapter<FriendInfo> {
public CustomAdapter (Context context, int textViewResourceId,
ArrayList<FriendInfo> friendList) {
super(context, textViewResourceId, friendList);
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
try {
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.friend_item, null);
}
if(isViewInvitations){
Button btn_AcceptFrndReq = (Button)v.findViewById(R.id.btnAcceptFrndReq);
Button btn_DelFrnd = (Button)v.findViewById(R.id.btnDelFrnd);
btn_DelFrnd.setClickable(true);
btn_AcceptFrndReq.setVisibility(View.VISIBLE);
btn_DelFrnd.setVisibility(View.VISIBLE);
btn_AcceptFrndReq.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Toast.makeText(getContext(), "Accept", Toast.LENGTH_LONG);
}
});
btn_DelFrnd.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
//do delete call here in new thread
Toast.makeText(context, "Delete", Toast.LENGTH_LONG);
}
});
}
@Ajzaz背景:您能否將您的完整代碼發佈在pastebin.com – 2010-12-07 09:52:50