user1914811
user1914811

Reputation:

Auto complete text view is not working

Auto complete text view is not working in android version 2.3

Iam developing an app in which i uses an Auto complete Text view

The auto complete works fine when tested it with Android 4.0

But when iam using Android 2.3 the auto complete drop down is not showing More over any text entered in it also not visible

My code is given below

In onCreate

ArrayAdapter<String> adapter = new ArrayAdapter<String>
                      (this,android.R.layout.simple_list_item_1, itemClass);
className.setAdapter(adapter);
className.setThreshold(1); 

Upvotes: 2

Views: 1519

Answers (1)

user1724537
user1724537

Reputation:

The following link solved my issue pls have a try

  1. by using sqlite db

    http://saga-androidapplication.blogspot.in/2011/07/how-to-use-autocomplete-searchbox-in.html

the source code can be downloaded from

 http://media0.webgarden.com/files/media0:4e0f5e93920fd.rar.upl/AutoCompleteSample.rar

2.non dynamic

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.ArrayAdapter;
    import android.widget.MultiAutoCompleteTextView;

    public class Autocomplete extends Activity {
        /** Called when the activity is first created. */
        String[] names = 
        {
        "vasu","kamal","vimal","santhosh",
        "prabu","prakash",
        "bala","baskar",
        "arjun","aravind",
        "shankar","siva",
        "mani","manickam",
        "mohan",
        "eswar",
        "vikram",
        };
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
           ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,names);
            MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.books);
            //AutoCompleteTextView acTextView = (AutoCompleteTextView)findViewById(R.id.books);
            //textView.setThreshold(1);
            textView.setAdapter(adapter);
            textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
            //acTextView.setAdapter(adapter);
        }
    }

Source can be downloaded from

http://media0.webgarden.com/files/media0:4dd6666334cb7.rar.upl/Autocomplete.rar

First of all import this as a project and test in both device then try to integrate this with your app

Upvotes: 3

Related Questions