Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:53:14+00:00 2026-05-26T08:53:14+00:00

i’m making a listview ,but scrolling is too slow. i have a ImageButton and

  • 0

i’m making a listview ,but scrolling is too slow.
i have a ImageButton and TextView in a page.
if i click on ImageButton, i can get a photo from camera album.
if saving, image uri(camera Album) and texts are saved into database.
and then listview is getting data from database.

i can see image and text on the listview well.
but scrolling is too slow..
I use AsyncTask in this code, but as im a beginneer, i don’t know how to exactly use the AsyncTask for better scrolling

could anybody see my code and guide me?

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list);
    lv=(ListView)findViewById(R.id.listView1);
    new SubClass().execute();
}

/******************CustomCursorAdapter*******************/

public class CustomCusorAdapter extends CursorAdapter{  
    RelativeLayout listview_relative;

    public CustomCusorAdapter(Context context, Cursor c) {
        super(context, c);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void bindView(View v, Context context, Cursor cursor) {

        wrap = (ViewWrap) v.getTag();

        for(int i=0; i<cursor.getColumnCount();i++){

        }
        if(cursor.getPosition()%2==1){   //if position is odd, color is something.      

    wrap.getRelative().setBackgroundColor(0xfff0f8ff);  
        }
        else if(cursor.getPosition()%2==0){   //if position is even, color is something other.

            wrap.getRelative().setBackgroundColor(0xfffff5ee);
        }


        String titleText = cursor.getString(1);
        String bodyText = cursor.getString(2);
        String dateText = cursor.getString(3);
        imageStr = cursor.getString(4);

        wrap.getTitle().setText(titleText);
        wrap.getDate().setText(dateText);
        wrap.getBody().setText(bodyText);

        if(imageStr != null){
            uri = Uri.parse(imageStr);
            wrap.getImage().setImageURI(uri);
        }else{
            wrap.getImage().setImageResource(R.drawable.resize_camera_input_photo1);

        }
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        LayoutInflater inflater = getLayoutInflater();
        View v = inflater.inflate(R.layout.listview, null);
        ViewWrap wrap = new ViewWrap(v);
        v.setTag(wrap);
        return v;
    }

}//CustomCusorAdapter

/******* Sub AsyncTask***********************************************************/

class SubClass extends AsyncTask<Cursor, Cursor, Cursor>{

    @Override
    protected Cursor doInBackground(Cursor... params) {
        mydb = new MyDatabase(getBaseContext());    
        db = mydb.getReadableDatabase();
        cursor = db.rawQuery("select * from "+ TABLE_NAME + " order by _id desc;", null);       

        startManagingCursor(cursor);
        return cursor;
    }

    @Override
    protected void onPostExecute(Cursor result) {
        adapter = new CustomCusorAdapter(getBaseContext(), result);
        lv.setAdapter(adapter);
        mydb.close();
        db.close();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:53:14+00:00Added an answer on May 26, 2026 at 8:53 am

    Since you just scroll the list after the AsyncTask has returned, I do not think that this is a problem related to the fetching of the data..

    The adapter is the one that can take a set of optimizations:

    1. Do not use setters/getters to the ViewWrap class. Use public fields and access them directly.
    2. Do not create a LayoutInflater in every newView(). This is a quite consuming process.
    3. Save to this holder (ViewWrap) only the views that you want, and not the whole ViewGroup.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.