android - ListView selection problem with rating control? -
friends,
i have created simple custom listview adapter ratingbar in it.
now have noticed 1 thing cannot rate rating bars in listview because when click on listview row particular row gets selected.
any 1 guide me how select individual items in android listview?
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <listview android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/android:list" /> </linearlayout>
and listview_item design
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content"> <linearlayout android:layout_width="265dip" android:orientation="vertical" android:layout_height="wrap_content"> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/text1" android:textsize="25dip" android:text="this text1"/> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/text2" android:text="this text2"/> <ratingbar android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/ratingbarstylesmall" android:id="@+id/star" android:numstars="10" android:stepsize="0.1" android:isindicator="true" /> </linearlayout> </linearlayout>
any appreciated.
dear umar in order implement listeners each element listview(single row) use custom adapter , in getview(....) method of custom adapter ,implements listeners u want.. sample code `public class findfriendslistadapter extends baseadapter {
private arraylist<singleelementdetails> allelementdetails; private layoutinflater minflater; private context context; private string userid1; private int usersno1; private dbadapter db; public findfriendslistadapter(context context, arraylist<singleelementdetails> results,string userid,int usersno) { this.context=context; this.userid1=userid; this.usersno1=usersno; allelementdetails = results; minflater = layoutinflater.from(context); db=new dbadapter(context); db.open(); } public int getcount() { return allelementdetails.size(); } public object getitem(int position) { return allelementdetails.get(position); } public long getitemid(int position) { return position; } public view getview(final int position, view convertview, viewgroup parent) { convertview = minflater.inflate(r.layout.friendlisthelper, null); imageview imageview = (imageview) convertview.findviewbyid(r.id.friendimageview); textview textview = (textview) convertview.findviewbyid(r.id.friendtextview); button button=(button)convertview.findviewbyid(r.id.friendbutton); convertview.setonclicklistener(new onclicklistener(){ public void onclick(view v) { //do u want } }); button.setonclicklistener(new onclicklistener(){ @override public void onclick(view v) { // u want } }); return convertview; }
} `
Comments
Post a Comment