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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:55:01+00:00 2026-05-30T18:55:01+00:00

I created a database with data that I put into a ListView . Since

  • 0

I created a database with data that I put into a ListView. Since it was created programmatically, there is no xml file that contains this ListView. Code:

public class hornot extends Application{

  public static final String KEY_ROWID = "_id";
  public static final String KEY_NAME = "persons_name";
  public static final String KEY_HOTNESS = "persons_hotness";
  public static final String DATABASE_NAME = "HotOrNotdb";
  private static final String DATABASE_TABLE = "peopleTable";
  private static final int DATABASE_VERSION = 1;

  private DbHelper ourHelper;
  private final Context ourContext;
  private SQLiteDatabase ourDatabase;

  private static class DbHelper extends SQLiteOpenHelper {
  public DbHelper(Context context) {
  super (context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
  db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" + 
   KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
   KEY_NAME + " TEXT NOT NULL, " +
   KEY_HOTNESS + " TEXT NOT NULL);"
   );

  }
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
  onCreate(db);
  }

   }
 public hornot(Context c) {
  ourContext = c;
  }

 public hornot open() throws SQLException{ //ez a throws kell az SQLiteExample.java try részhez
  ourHelper = new DbHelper(ourContext);
  ourDatabase = ourHelper.getWritableDatabase();
  return this;
  }

This is how I put the items into the ListView:

 ListView lv;
  ArrayList<String> todoItems = new ArrayList<String>();
 ArrayList<String> todoItems2 = new ArrayList<String>();

  @Override
  protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, todoItems));

   final ListView lv = getListView();
   lv.setTextFilterEnabled(true);
  final hornot info = new hornot(this);
  info.open();

  Cursor c = info.getAllTitles();
  if (c.moveToFirst())
        {
        do{
                 todoItems.add(c.getString(0) + " " + c.getString(1) + " " + c.getString(2));
         }while (c.moveToNext());
       }
            if (todoItems.size() > 0)
            {
        lv.setAdapter(new ArrayAdapter<String>(sqview.this,android.R.layout.simple_list_item_1, todoItems));
            }

I created an xml and I’d like to put the programmatically created ListView into another ListView(with the id listplus):

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <Button android:text="Button" android:id="@+id/b1"
  android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  <Button android:text="Button" android:id="@+id/b2"
  android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  <ListView android:id="@+id/listplus" android:layout_height="wrap_content"
  android:layout_width="fill_parent"><;/ListView>
</LinearLayout>

How could I do that?

  • 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-30T18:55:02+00:00Added an answer on May 30, 2026 at 6:55 pm

    I think that you just want an ListActivity with a custom layout. Right now you use a ListActivity(that by default shows just a full screen list), if you want to have other elements besides the list(buttons, images etc) set the content view to a xml layout. If you set your content view to a custom layout, in that layout you must have a ListView with the id "@android:id/list" so that your ListView knows where to bind the data. So if you want to use the layout you posted modify it and add the required id to the list:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      <Button android:text="Button" android:id="@+id/b1"
      android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
      <Button android:text="Button" android:id="@+id/b2"
      android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
      <ListView android:id="@android:id/list" android:layout_height="wrap_content"
      android:layout_width="fill_parent"></ListView>
    </LinearLayout>
    

    Then in your current ListActivity that you used just add the line:

    @Override
      protected void onCreate(Bundle savedInstanceState){
         super.onCreate(savedInstanceState);
         setContentView(R.layout.the_name_of_above_layout); // <=this line
         setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, todoItems));
    
         final ListView lv = getListView();
         lv.setTextFilterEnabled(true);
         final hornot info = new hornot(this);
         info.open();
    
         Cursor c = info.getAllTitles();
         if (c.moveToFirst()) {
            do {
                todoItems.add(c.getString(0) + " " + c.getString(1) + " " + c.getString(2));
            } while (c.moveToNext());
         }
         if (todoItems.size() > 0) {
            lv.setAdapter(new ArrayAdapter<String> (sqview.this,android.R.layout.simple_list_item_1, todoItems));
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a database that stores data from the internet.When there is internet
MYSQL Database: I have a table of data that I need to put into
I just created a PHP page that spits outs some data from my database
I want to allow user to put his data into text filed . that
I inherited MYSQL database that has lots of tables with data like CREATE TABLE
How do you create a database from an Entity Data Model. So I created
I've met an unknown error while inserting data into the database. The LogCat had
I have data coming in from datastage that is being put in our SQL
I have a problem with inserting data into SQLite database using QSqlTableModel. The table
I have an Excel Spreadsheet that contains all my data that I need to

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.