Onclick Button Is Not Working In Listview
Solution 1:
The problem is in onInterceptTouchEvent method. You are using IndexableListView from woozzu, and this class overrides onInterceptTouchEvent to return true. This means that IndexableListView always steal touch events from your child's views so it can provide it to IndexScroller. You can change this behavior if instead of returning true you enter this condition:
@OverridepublicbooleanonInterceptTouchEvent(MotionEvent ev) {
if (mScroller != null && mScroller.contains(ev.getX(), ev.getY()))
returntrue;
returnsuper.onInterceptTouchEvent(ev);
}
This way only events meant to interact with IndexScroller will be consumed. Other events will be propagated to children's views, and your button will be clickable.
Solution 2:
In your Efficient adapter class declare ViewHolder holder
outside getView method
and do as MoshErsan said.
Also Change your
convertView = mInflater.inflate(R.layout.homemplebrowview, null);
to
convertView = mInflater.inflate(R.layout.homemplebrowview, parent,false);
Solution 3:
in your adapter, just move
holder.btnList.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View v) {
Toast.makeText(context, "STAT", Toast.LENGTH_SHORT).show();
Intentnext=newIntent(context, Home.class);
Log.i("next23", "next");
context.startActivity(next);
}
});
just before return convertView;
you need to set the listener every time the adapter returns a view.
Post a Comment for "Onclick Button Is Not Working In Listview"