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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:01:01+00:00 2026-05-25T23:01:01+00:00

I have a ListView and a Arrayadapter filled with Strings. The data should be

  • 0

I have a ListView and a Arrayadapter filled with Strings. The data should be the StringArray myStrings

My Code:

    public class Main extends Activity {
        private SQLiteDatabase myDB;
        final String MY_DB_NAME = "PizzaCounter";
        final String MY_DB_TABLE = "Pizza";
        private ListView lv;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Log.e("XXX", "Start");
            lv = ((ListView)findViewById(R.id.list));
            Log.e("XXX List View",lv.toString());
                onCreateDBAndDBTabled();
                Button bt = (Button)findViewById(R.id.bt_add);


                bt.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        startActivityForResult(new Intent(Main.this, AddPizza.class), 1);

                    }
                });

            }
            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());
              Log.e("XXX", "Item[0] -->" +  list.toArray()[0].toString());
              String[] mStrings = new String[] { "Nyros", "Mobile", "Android" }; 
             ArrayAdapter<String> aa = new ArrayAdapter<String>(Main.this, android.R.layout.simple_list_item_1, mStrings);
    Log.e("XXX", String.valueOf(aa.getCount()));
              lv.setAdapter(aa);
            }


The problem is that no item is shown and the list count is 3.

LogCat:

09-29 08:43:03.344: ERROR/XXX(461): Start

09-29 08:43:03.344: ERROR/XXX List View(461): android.widget.ListView@43d13918

09-29 08:43:03.384: ERROR/XXX(461): Courser Enter: EditText

09-29 08:43:03.394: ERROR/XXX(461): Count:1

09-29 08:43:03.394: ERROR/XXX(461): Item[0] -->EditText

09-29 08:43:03.394: ERROR/XXX(461): 3

Layout:

    <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
        <Button android:text="hinzufügen" android:id="@+id/bt_add" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>

        <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView>
        </LinearLayout>
  • 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-25T23:01:04+00:00Added an answer on May 25, 2026 at 11:01 pm

    Your problem is in the layout – the linear layout defaults to a horizontal orientation which means the button (which is set to fill_parent) will fill the screen leaving no room for the listview.

    If you add the attribute:

    android:orientation="vertical"
    

    to your LinearLayout then you should see the list.

    Hope that works!

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

Sidebar

Related Questions

I have a listview with a custom array adapter: public class SmsMessageAdapter extends ArrayAdapter<ContactMessage>
I have ListView activity class: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] naziviMolitvi =
Hy!! I have a listview that should be filled with data from the database
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have a ListView that is filled with items of an ArrayAdapter. Now I
I have a listview with a custom arrayadapter that handles about 15 strings. The
I have a ListView with an ArrayAdapter providing the data. I'm adding paging, so
I want to have a listview with a custom adatper, extends ArrayAdapter, where Type
I have an ArrayAdapter powering a ListView . I would like to change the
I have a ListView that I want to use with an ArrayAdapter to add

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.