2

I am use data from web using XML parser and setting data using custom adapter for this use asyncTask . My problem is that some devices like Samsang duos,gallaxy work perfectly but on micromax devices it will not work properly.

My adapter is

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; } 

}

3 Answers 3

1

read it listview smooth-scrolling

Using a background thread ("worker thread") removes strain from the main thread so it can focus on drawing the UI. In many cases, using AsyncTask provides a simple way to perform your work outside the main thread. AsyncTask automatically queues up all the execute() requests and performs them serially. This behavior is global to a particular process and means you don’t need to worry about creating your own thread pool.

check this too http://www.itworld.com/development/380008/how-make-smooth-scrolling-listviews-android

Sign up to request clarification or add additional context in comments.

Comments

0

Put all your font styles in the if (convertView==null) {} block to set them only once. Now you are setting them every time a new row is created.

Comments

0

Here is a list of quick tips to help you.

  1. Reduce the number of conditions used in the getView of your adapter.

  2. Check and reduce the number of garbage collection warnings that you get in the logs

  3. If you're loading images while scrolling, get rid of them.

  4. Set scrollingCache and animateCache to false (more on this later)

  5. Simplify the hierarchy of the list view row layout

  6. Use the view holder pattern

Here is a link to help you implement these tips. Link

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.