wie smooth-scroll-listview wie ios in android?
Ich bin Verwendung von Daten aus dem web über XML-parser und Einstellung von Daten mithilfe von benutzerdefinierten adapter verwenden asyncTask .
Mein problem ist, dass einige Geräte, wie das Samsang duos,gallaxy perfekt funktionieren, aber auf micromax-Geräten wird nicht richtig funktionieren.
Mein adapter ist
public class HallBookingAdapter extends ArrayAdapter<MyHall> {
private Context context;
private ArrayList<MCCIAHall> halls;
private int resource;
MyHall objHall;
public int count;
View view;
public static Boolean isScrollingHalls=true;
LayoutInflater inflater;
static class HallBookingHolder
{
public TextView txtTitle,txtLocation,txtCapacity,txtCapacityTitle;
public ImageView imgHall;
public LinearLayout hallBookingLayout;
}
public HallBookingAdapter(Context context, int resource, ArrayList<MyHall> halls) {
super(context, resource, halls);
this.context=context;
this.halls=halls;
this.resource=resource;
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
count=halls.size();
return halls.size();
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
view=convertView;
objHall=halls.get(position);
HallBookingHolder holder=new HallBookingHolder();
if (convertView==null) {
view = inflater.inflate(resource, null);
holder.txtTitle=(TextView)view.findViewById(R.id.txtListHallTitle);
holder.txtLocation=(TextView)view.findViewById(R.id.txtListHallLocation);
holder.txtCapacity=(TextView)view.findViewById(R.id.txtListHallCapacity);
holder.txtCapacityTitle=(TextView)view.findViewById(R.id.txtListHallCapacityHeadding);
holder.imgHall=(ImageView)view.findViewById(R.id.imgListHall);
view.setTag(holder);
}
else
{
holder = (HallBookingHolder)convertView.getTag();
}
//Creating the Font to the text
Typeface tfLight = Typeface.createFromAsset(context.getAssets(),"OpenSans-Light.ttf");
Typeface tfRegular = Typeface.createFromAsset(context.getAssets(),"OpenSans-Regular.ttf");
Typeface tfsemiBold = Typeface.createFromAsset(context.getAssets(),"OpenSans-Semibold.ttf");
//Setting the font
holder.txtTitle.setTypeface(tfRegular);
holder.txtLocation.setTypeface(tfLight);
holder.txtCapacity.setTypeface(tfsemiBold);
holder.txtCapacityTitle.setTypeface(tfLight);
//Setting data to textview and image
holder.txtTitle.setText(objHall.hallName);
holder.txtLocation.setText(objHall.location);
holder.txtCapacity.setText(objHall.capacity);
//Using Guild Library Image Load using image web url
String imgurl=objHall.getImageUrl();
Glide.load(imgurl).centerCrop().into(holder.imgHall);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(context, HallDetailsActivity.class);
intent.putExtra("position", position);
context.startActivity(intent);
}
});
return view;
}
}
Du musst angemeldet sein, um einen Kommentar abzugeben.
Lesen listview smooth-scrolling
prüfen http://www.itworld.com/development/380008/how-make-smooth-scrolling-listviews-android
Alle Schriftstile in der
if (convertView==null) {}
block, um Sie nur einmal. Jetzt sind Sie Einstellung Sie jedes mal, wenn eine neue Zeile erstellt wird.Hier ist eine Liste von Tipps, um Ihnen zu helfen.
Reduzieren Sie die Anzahl der Bedingungen, die in der getView des Adapters.
Überprüfen und reduzieren Sie die Anzahl der garbage collection-Warnungen, die Sie erhalten in den Protokollen
Wenn Sie das laden von Bildern beim scrollen, Sie loszuwerden.
Set scrollingCache und animateCache auf false (dazu später mehr)
Vereinfachung der Hierarchie in der Liste anzuzeigen Zeile layout
Verwenden Sie die Ansicht Halter pattern
Hier ist ein link zu helfen Ihnen bei der Umsetzung dieser Tipps. Link