0

I am trying to set up an AutoCompleteTextview in a activity. I get no errors. On the preview screen it looks like this(http://gyazo.com/7bf15e2b0b37f09d0d20ba883de49dce). However, when I run the app on my phone or on the emulator, it looks like this(http://gyazo.com/bf5d6cb733c03835a1061fd175c500a0) and no suggestions come up that I have listed when I type them in.

Here's my code, hopefully someone can help me out here:

search screen XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/search_screen_medium"
android:orientation="vertical" >

<AutoCompleteTextView
    android:completionThreshold="1"
    android:id="@+id/autocomplete"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginLeft="10dp"
    android:hint="@string/search_hint"
    android:paddingRight="10dp"
    android:ems="10"
    android:textColor="#FFFFFF" />
<requestFocus />
</LinearLayout>    

List detail XML:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/componentlistdetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20sp"
android:padding="10dp"
android:textColor="#FFFFFF" >


</TextView>

Java

package com.youtube.iamjackpot;

import android.R.string;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class SearchmenuActivity extends Activity {

String[] ComponentList = {

"Pizza", "Cheese", "Chocolate, "Cake", "Burger" };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_searchmenu);
    AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.autocomplete);
    actv.setAdapter(new ArrayAdapter<String>(this,R.layout.componentlistdetail, ComponentList));


};

}
Jaack
  • 31
  • 1
  • 7

1 Answers1

0

Pass ComponentList in your adapter

actv.setAdapter(new ArrayAdapter<String>(this,R.layout.componentlistdetail,ComponentList));
Srikanth Roopa
  • 1,782
  • 2
  • 13
  • 19
  • Thank you, Now the suggestions are appearing. Do you know why there isn't a proper box surrounding the search box like there is in the preview screen? Thanks – Jaack Jul 17 '13 at 13:05