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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:22:58+00:00 2026-06-02T21:22:58+00:00

I’m doing the Extra Credit section of the Adding a List section in Android

  • 0

I’m doing the Extra Credit section of the Adding a List section in Android Tutorials. I tried populating the AutoCompleteTextView (ACTV) with the items contained in the ArrayAdapter, but if the addr field has characters in it above the threshold limit, the list doesn’t show any items. Here is the code:

public class MyActivity extends Activity
{
List<Restaurant> model = new ArrayList<Restaurant>();
ArrayAdapter<Restaurant> adapter = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button save = (Button)findViewById(R.id.save);
    save.setOnClickListener(onSave);

    ListView list = (ListView)findViewById(R.id.restaurants);

    adapter = new ArrayAdapter<Restaurant>(this,
                    android.R.layout.simple_list_item_1,
                    model);
    list.setAdapter(adapter);

    AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.addr);
    textView.setAdapter(adapter);
}

private View.OnClickListener onSave= new View.OnClickListener(){
    ...
};
}

And the XML…

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
<TableLayout
    android:id="@+id/details"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:shrinkColumns="1"
    android:layout_alignParentBottom="true"
    >
    <TableRow>
        <TextView android:text="Name:"/>
        <EditText android:id="@+id/name"/>
    </TableRow>

    <TableRow>
        <TextView android:text="Address:"/>
        <AutoCompleteTextView android:id="@+id/addr"
                              android:completionThreshold="5"
                />
    </TableRow>
    <TableRow>
        <TextView android:text="Type:"/>
        <RadioGroup android:id="@+id/types">
            <RadioButton android:id="@+id/take_out"
                         android:text="Take Out"
                         android:layout_height="wrap_content"
                         android:layout_width="wrap_content"
                         android:checked="true"
                         />
            <RadioButton android:id="@+id/sit_down"
                         android:text="Sit Down"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"/>
            <RadioButton android:id="@+id/delivery"
                         android:text="Delivery"
                         android:layout_height="wrap_content"
                         android:layout_width="wrap_content"/>
        </RadioGroup>
    </TableRow>
    <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/save"
            android:text="Save"/>
</TableLayout>
<ListView android:id="@+id/restaurants"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_above="@id/details"/>
</RelativeLayout>

Changing the completionThreshold changes the number of characters I can enter before the items in the List disappear.

Thanks for the 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-06-02T21:23:00+00:00Added an answer on June 2, 2026 at 9:23 pm

    You are attempting to use the same adapter for both the ListView and the AutoCompleteTextView. That is not a good idea. Please use separate adapters. You might even want a separate layout for the adapter used with the AutoCompleteTextView (e.g., android.R.layout.simple_dropdown_item_1line, as I used in this sample project).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.