Onitemclick listener not triggered in Listview
I have a listview, and I am using OnItemClickListener for that listview.
At the same time, in getview method of my custom adapter I am using
onclicklistener for the entire row view.And I figured out that when using
Onclicklisnter in custom adapter, my OnItemClickListener of listview is
not triggered. I want to use both these listeners at the same time. Can
anyone help me to do it? Thanks in advance.
My listview listener,
list_specialists.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HashMap<String, String> trends_data= new HashMap<String,
String>();
trends_data = specobj.get(position);
specialist.setText(trends_data.get(KEY_SPEC_TITLE));
new GetTime(BookingActivity.this).execute();
}
});
And my getview method inside custom adapter,
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = convertView;
final ViewHolder holder;
if (rowView == null) {
rowView = inflater.inflate(R.layout.row_timeslot, parent, false);
holder = new ViewHolder();
holder.title = (TextView) rowView.findViewById(R.id.textView2);
holder.layout = (RelativeLayout) rowView
.findViewById(R.id.relativeLayout1);
holder.check = (org.holoeverywhere.widget.CheckBox) rowView
.findViewById(R.id.checkBox1);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
HashMap<String, String> trends_data = new HashMap<String, String>();
trends_data = trendsobj.get(position);
holder.check.setId(position);
holder.check.setChecked(checkarry[position]);
// for managing the state of the boolean
// array according to the state of the
// CheckBox
holder.check.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.layout.setOnClickListener(new View.OnClickListener() { // Here
I am using onclicklistener for rows's parent layout.
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.title.setText(trends_data.get(BookingActivity.KEY_TIME_TITLE));
return rowView;
}
No comments:
Post a Comment