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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:23:05+00:00 2026-06-04T20:23:05+00:00

I have the following class which as you can see contains a EditText, Button

  • 0

I have the following class which as you can see contains a EditText, Button and list.
I want the user to type in the EditText some text,click Search and Show up the results from

SQLite database in the list below the button/edittext field.
public class FindOrder  extends ListActivity {
private List<String> arr;
private ListView listView;
Button search;
EditText search_field;
String search_val;
SQLiteDatabase db = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.find_order);
    // TODO Auto-generated method stub
    Log.e("myTag","in func");
    search = (Button) findViewById(R.id.search_button);
    search_field = (EditText) findViewById(R.id.search_field);
    search.setOnClickListener(  
            new View.OnClickListener() {
                public void onClick(View view) {
                    search_val=search_field.getText().toString();
                    //getOrder(search_val);

                }
            });
}

public void getOrder(String val) {
    Log.e("myTag","in func");
    String query;
    String[] s_arr = new String[1];
    listView = (ListView) findViewById(R.id.listView);
    ArrayAdapter<String> adapter;
    arr = new ArrayList<String>();
    db =  this.openOrCreateDatabase( "DBname", MODE_PRIVATE, null);
    query="SELECT OrderName, OrderLink, DateYear, DateMonth, DateDay, OrderPrice FROM Orders where OrderName=?";
    s_arr[0]=val;
    Cursor c = db.rawQuery(query, s_arr);
    if (c != null ) {
       if  (c.moveToFirst()) {
           do {     
               arr.add(c.getString(c.getColumnIndex(DatabaseHelper.colName)));
               Log.e("myTag",c.getString(c.getColumnIndex(DatabaseHelper.colName)));
           } while (c.moveToNext());
       }
   } 
   c.close();
  //setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr));
  adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, arr);
  listView.setAdapter(adapter);
  TextView textview = new TextView(this);
  LinearLayout ll2 = (LinearLayout)findViewById(R.id.linearLayout2);
  ll2.addView(textview);

}
}

Currently whenever i click on the button in Main Menu which leads to this activity, i get an FC.
One of the errors i can see i the log is :

06-02 10:32:18.387: E/AndroidRuntime(1904): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Sagi.MyOrders/com.Sagi.MyOrders.FindOrder}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

Together with many other errors . But i couldn’t really understand why should i have .list attribute …

XML :

<?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" >
    <LinearLayout
        android:id = "@+id/linearLayout1"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <EditText
                android:id="@+id/search_field"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10" >
        </EditText>
        <Button
            android:id="@+id/search_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Search" />
    </LinearLayout>
    <LinearLayout
        android:id = "@+id/linearLayout2"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </LinearLayout>
    <ListView
            android:id="@+id/listView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
</LinearLayout>

Thanks !

  • 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-06-04T20:23:09+00:00Added an answer on June 4, 2026 at 8:23 pm

    just change this line in xml file where you declare listview.

    android:id="@android:id/list" 
    

    No need to declare listview. Please try below code.

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, values);
    setListAdapter(adapter);
    

    Please check below example.

    public class MyListActivity extends ListActivity {
        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
                    "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
                    "Linux", "OS/2" };
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, values);
            setListAdapter(adapter);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following class which handles my user logged in / logged out
I have the following City class. Each city object contains a dictionary which keys
I have the following abstract class which CAN NOT be changed. public abstract class
I want to create a class which wraps a list of structures. I have
I have the following script which creates 2 threads as you can see.The thing
I have a class LINE which contains two properties of type POINT. I would
In C++, I have a class which contains an anonymous bitfield struct. I want
Let's say you have a class called Customer, which contains the following fields: UserName
I have following class which reads and writes an array of objects from/to a
I have the following asynctask class which is not inside the activity. In the

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.