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 7688947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:02:50+00:00 2026-05-31T20:02:50+00:00

First off thanks to all the users who have made my android developing adventure

  • 0

First off thanks to all the users who have made my android developing adventure so much easier. I have, however, come across a situation for which I don’t find a solution so here goes:

I have an Activity which contains various Fragments which are intended to interact with each other. These include:

  1. a Fragment containing a GridView populated by a SimpleCursorAdapter from one table in the Sqlite db

    // Grid Functionality
    
    public void PopulateGrid(){
    dba = new myDB(getActivity().getApplicationContext());
    dba.open();
    Cursor c = dba.getRows();
    if (c!=null){
    String[] columns = new String[]{col_1, col_2, col_3, col_4};
    int[] to = new int[]{R.id.grid_id, R.id.grid_desc, R.id.grid_value, R.id.grid_image};
    
    newAdapter = new SimpleCursorAdapter(getActivity(), R.layout.grid_item, c, columns, to); 
    
    View v = getView();
    GridView gv = (GridView)v.findViewById(R.id.sale_grid);
    gv.setAdapter(newAdapter);
    gv.setOnItemClickListener(itemSelected);
    
    }
    }
    
  2. a ListFragment which is populated by another SimpleCursorAdapter from a different table
    // List Functionality

    public void PopulateList(int index){
    Log.v("sell list", "Populate list started");
    dba.open();
    Cursor cursor = dba.getList(index);
    if (cursor!=null){
    String[] columns = new String[]{col_1, col_2, col_3, col_4, col_5};
    
    int[] to = new int[]{R.id.code, R.id.description, R.id.qty, R.id.price};
    
    newAdapter = new SimpleCursorAdapter(getActivity(), R.layout.list_row, cursor, columns, to); 
    this.setListAdapter(newAdapter);
    
    }
    dba.close();
    
    }
    
  3. When the user selects something from the GridView, the Activity inserts the item in the ListView’s table and then reinitializes it.

    @Override
    public void onGridClicked(Long value) {
    insertItem(value.toString());
    }
    //do stuff
    
    public void insertItem(String result) {
    
        // Add item
        dba.addItem(result, qty, index);
        //Re-populate Panels 
        long start;
        long end;
    
        start = System.currentTimeMillis();
        refreshPanels(index);
        end = System.currentTimeMillis();
        Log.v("Refresh List:", "Time"+(end-start));
    
    }
    private void refreshPanels(int index){
        lf.PopulateList(index);
        ListView lv = lf.getListView();
        lv.setSelection(lv.getCount()-1);
    
    }
    

Now for the problem: When I look at the logs and Log each step. This entire process take no more than 50-70 ms but from the time I click on the Grid to the time the ListView is updated I can literally count 2-3 seconds.
It seems that the issue lies in the ListFragment and the time it takes to setListAdapter() and refresh the View.

I have tried various ways of going about this such as 1. using an Interface to listen for the selection or calling it directly from the GridView fragment 2. calling a secondary function in the ListFragment with either newadapter.changecursor(c) or newadapter.getCursor().requery() 3. other variants of this…

But it always seems to take forever any help please..

  • 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-31T20:02:51+00:00Added an answer on May 31, 2026 at 8:02 pm

    thanks for the help, turns out the issue is not in the ListView loading the data, but rather the GridView taking too long to register the click see topic 5197438 Now I gotta figure out a way around it…

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

Sidebar

Related Questions

First off, thanks to whomever is reading this. I have a very strange problem
First off, I am using Windows XP. I have multiple hard drives and it
First of all, let me say I am very new to rails, have been
First off all I know: Premature optimization is the root of all evil But
First off, I am personally against obfuscation and agree with others who are so,
First off, The Problem: We have a Web App with a Flash front-end that
First off, I understand the reasons why an interface or abstract class (in the
First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.
First off, there's a bit of background to this issue available on my blog:
First off: I'm using a rather obscure implementation of javascript embedded as a scripting

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.