Sunday 15 June 2014

android - ListView Scrolls so slow -



android - ListView Scrolls so slow -

my listview scrolls slow iam using horizontallistview

iam trying accomplish horizontallistview footer in other listview

or header , working slow , not working correctly.

so custome adapter

public class horizntallmedialist extends arrayadapter<itemsmediasuggestion> { string imageurl; context context; int table = 0; list<itemsmediasuggestion> objects; itemsmediasuggestion related; public horizntallmedialist(context context, int textviewresourceid, list<itemsmediasuggestion> objects, int table) { super(context, textviewresourceid, objects); this.context = context; this.objects = objects; this.table = table; } viewholder holder = new viewholder(); private class viewholder { private relativelayout relativelayout; private imageview userimage, addimage; private textview username; } @override public long getitemid(int position) { homecoming super.getitemid(position); } @override public int getcount() { homecoming super.getcount(); } @override public itemsmediasuggestion getitem(int position) { homecoming super.getitem(position); } @override public view getview(final int position, view convertview, viewgroup parent) { try{ related = getitem(position); } grab (indexoutofboundsexception e) { } layoutinflater inflater = (layoutinflater) context .getsystemservice(activity.layout_inflater_service); if (convertview == null) { convertview = inflater.inflate(r.layout.items_wall_horizntal, parent, false); holder = new viewholder(); holder.relativelayout = (relativelayout) convertview .findviewbyid(r.id.horrelative); holder.userimage = (imageview) convertview .findviewbyid(r.id.horuserimage); holder.username = (textview) convertview.findviewbyid(r.id.horname); holder.addimage = (imageview) convertview.findviewbyid(r.id.horadd); holder.addimage.setvisibility(view.gone); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } holder.relativelayout .setbackgroundcolor(globalconstants.colorpicker_int); if (table == 5) { imageurl = globalconstants.server_file + table + "/m/" + related.getstorage() + "." + related.getstoragerand() + ".jpg"; holder.username.settext(publicmethods.readable(related .getdescribtion())); } else if (table == 6) { if (related.getstorage().equals("0")) { holder.username.settext(publicmethods.readable(related .gettitle())); imageurl = "https://img.youtube.com/vi/" + related.getstoragerand() + "/1" + ".jpg"; } else { imageurl = globalconstants.server_file + table + "/m/" + related.getstorage() + "." + related.getstoragerand() + ".jpg"; holder.username.settext(publicmethods.readable(related .gettitle())); } } else { imageurl = globalconstants.server_file + 5 + "/m/" + related.getstorage() + "." + related.getstoragerand() + ".jpg"; holder.username.settext(publicmethods.readable(related.gettitle())); } picasso.with(context).load(imageurl).fit().into(holder.userimage); homecoming convertview; } }

this item xml :

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/background_with_shadow" android:orientation="vertical" > <relativelayout android:layout_width="200dp" android:layout_height="200dp" > <imageview android:id="@+id/horuserimage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_alignparenttop="true" /> <relativelayout android:id="@+id/horrelative" android:layout_width="match_parent" android:layout_height="40dp" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" > <textview android:id="@+id/horname" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_centervertical="true" android:layout_marginleft="20dp" android:layout_marginright="5dp" android:layout_toleftof="@+id/horadd" android:gravity="right" android:maxlines="1" android:text="name" android:textcolor="@color/whitecolor" android:textsize="18sp" /> <imageview android:id="@+id/horadd" android:layout_width="40dp" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:src="@drawable/plus" /> </relativelayout> </relativelayout>

the listview xml:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:id="@+id/horizntalllin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margintop="20dp" android:background="@android:color/transparent" android:orientation="vertical" android:visibility="visible" > <relativelayout android:layout_width="match_parent" android:layout_height="250dp" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="3dp" android:layout_marginright="3dp" android:background="@drawable/background_with_shadow" > </relativelayout> <textview android:id="@+id/horizntalladvertisetext" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:paddingleft="15dp" android:paddingright="15dp" android:text="@string/relatedtopics_st" android:textappearance="?android:attr/textappearancemedium" android:textstyle="bold" /> <utilityfunction.horizontallistview android:id="@+id/hotrizantellistviewmedia" android:layout_width="fill_parent" android:layout_height="200dp" android:layout_below="@+id/horizntalladvertisetext" android:listselector="@android:color/white" android:saveenabled="true" android:smoothscrollbar="true" > </utilityfunction.horizontallistview> </relativelayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="3dp" android:layout_marginright="3dp" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" " android:visibility="invisible" /> </linearlayout> </linearlayout>

try :

<listview ... android:smoothscrollbar="true"/>

android listview

No comments:

Post a Comment