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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:48:45+00:00 2026-05-26T00:48:45+00:00

Hy! I load data from my Db and I will show it in a

  • 0

Hy! I load data from my Db and I will show it in a ListView. Tha problem is that no item is shown. The Listcount is 1. The list gets the data from the db. No error occures. I have no idea why.

Code:

public class Main extends Activity {
    private ListView lv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        lv = ((ListView)findViewById(R.id.list));
        Log.e("XXX List View",lv.toString());
        onCreateDBAndDBTabled();            
    }

    private void onCreateDBAndDBTabled() {
        myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
        myDB.execSQL("CREATE TABLE IF NOT EXISTS " + MY_DB_TABLE
                + " (_id integer primary key autoincrement, name varchar(100), rate integer(1), eattime datetime)"
                +";");

        List<String> list = new ArrayList<String>();
        Cursor cursor = this.myDB.query(MY_DB_TABLE, new String[] { "name" }, null, null, null, null, null, null);

        if (cursor.moveToFirst()) {
            do {
                Log.e("XXX", "Courser Enter: " + cursor.getString(0));
                list.add(cursor.getString(0)); 
            } while (cursor.moveToNext());
        }

        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }

        Log.e("XXX", "Coung:" + list.size());

        ArrayAdapter<String> aa = new ArrayAdapter<String>(Main.this, android.R.layout.simple_list_item_1, list);
        lv.setAdapter(aa);
    }
}

Log:

09-23 08:49:30.030: ERROR/XXX(6673): Start
09-23 08:49:30.030: ERROR/XXX List View(6673): android.widget.ListView@43d13918
09-23 08:49:30.080: ERROR/XXX(6673): Courser Enter: EditText
09-23 08:49:30.090: ERROR/XXX(6673): Coung:1

Please help

  • 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-26T00:48:45+00:00Added an answer on May 26, 2026 at 12:48 am

    First check your list object is null or not ……… then

    http://sudarmuthu.com/blog/using-arrayadapter-and-listview-in-android-applications

    http://www.dotnetexpertsforum.com/populate-listview-using-arrayadapter-in-android-t1437.html

    https://github.com/sudar/android-samples

    also check List list = new ArrayList(); size there are list is empty or not if empty try to get element………….

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

Sidebar

Related Questions

I want to load data from Internet. While loading data I show a loading
The function below will make an Ajax call to load data from a mySQL
Apache Pig can load data from Hadoop sequence files using the PiggyBank SequenceFileLoader :
I have a form with a DataGridView and I want to load data from
I'm facing a rather strange Issue when trying to load data from an XML-Webservice.
ViewA load some data from Coredata, then push to the next viewB . In
I want to load some data from mysql into my cocoa application view before
As part of a bulk load of data from an external source the stageing
I wish to load some additional data from javascript in an HTML page. The
I'm writing a little utility to load Entity Data Models from an assembly and

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.