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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:04:41+00:00 2026-06-03T15:04:41+00:00

i’m having some trouble with the autocomplete textview in android. I populate the array

  • 0

i’m having some trouble with the autocomplete textview in android. I populate the array with contact names but still it gives me this errors. What can be wrong?

Here is the code:

           @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        contactArr = new ArrayList<Contacts>();
        names=new ArrayList<String>();
        t = (TextView) findViewById(R.id.textView1);
        et = (EditText) findViewById(R.id.editText1);
        button = (Button) findViewById(R.id.button1);
        test();
        Log.v("test", names.get(3));
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                R.layout.list_item, names);
//      autoComplete.setThreshold(2);
        autoComplete.setAdapter(adapter);
        button.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

            }
        });
}

Here is how names arraylist is populated:

Cursor phones = getContentResolver().query(
                ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,
                null, null);
        while (phones.moveToNext()) {
            String name = phones
                    .getString(phones
                            .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
            String phoneNumber = phones
                    .getString(phones
                            .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
            names.add(name); //populated here

And finally the errors from logcat:

04-30 19:26:15.389: E/AndroidRuntime(25176): FATAL EXCEPTION: main
04-30 19:26:15.389: E/AndroidRuntime(25176): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.contact/com.contact.ContactInfoActivity}: java.lang.NullPointerException
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.os.Looper.loop(Looper.java:130)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread.main(ActivityThread.java:3835)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at java.lang.reflect.Method.invokeNative(Native Method)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at java.lang.reflect.Method.invoke(Method.java:507)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at dalvik.system.NativeStart.main(Native Method)
04-30 19:26:15.389: E/AndroidRuntime(25176): Caused by: java.lang.NullPointerException
04-30 19:26:15.389: E/AndroidRuntime(25176):    at com.contact.ContactInfoActivity.onCreate(ContactInfoActivity.java:41)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 19:26:15.389: E/AndroidRuntime(25176):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
04-30 19:26:15.389: E/AndroidRuntime(25176):    ... 11 more

When i remove this line autoComplete.setThreshold(2);
the new error in log cat is->

04-30 19:37:10.319: E/AndroidRuntime(25564):    at com.contact.ContactInfoActivity.onCreate(ContactInfoActivity.java:42)
  • 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-03T15:04:43+00:00Added an answer on June 3, 2026 at 3:04 pm

    If autoComplete.setThreshold(2); causes a null pointer, then it sounds like you haven’t defined autoComplete.

    You need to set it up similar to this:

    AutoCompleteTextView autoComplete = (AutoCompletetextView) findViewById(R.id.autoComplete);
    
    • 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
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is 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.