Hi,
I'm having problem with creating AutocompleteTextView in custom
dialog. In every example i saw, the autocomplete feature is only in
the classes that extends activity. I need to have autocomplete in
custom dialog that I created. The problem is that this:


 AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.autocomplete_country);
                    ArrayAdapter<String> adapter = new 
ArrayAdapter<String>(this,
R.layout.list_item, COUNTRIES);
                    textView.setAdapter(adapter);

should be in onCreate method that I don't have.
The errors are:

Multiple markers at this line
        - COUNTRIES cannot be resolved to a variable
        - The constructor ArrayAdapter<String>(quickfind, int, String[]) is
         undefined


My entire code for quickfind.java:

import android.R.string;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;

/** Class Must extends with Dialog */
/** Implement onClickListener to dismiss dialog when OK Button is
pressed */
public class quickfind extends Dialog implements OnClickListener {
        Button okButton;

                            public quickfind(Context context) {
                super(context);
                /** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
                requestWindowFeature(Window.FEATURE_NO_TITLE);
                /** Design the dialog in main.xml file */
                setContentView(R.layout.quickfind);
                okButton = (Button) findViewById(R.id.close);
                okButton.setOnClickListener(this);


                 AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.autocomplete_country);
                    ArrayAdapter<String> adapter = new 
ArrayAdapter<String>(this,
R.layout.list_item, COUNTRIES);
                    textView.setAdapter(adapter);

        }

        static final String[] COUNTRIES = new String[] {
                  "Afghanistan", "Albania", "Algeria", "American Samoa", 
"Andorra",
                  "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda",
"Argentina",
                  "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
                  "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium"
                };


        @Override
        public void onClick(View v) {
                /** When OK Button is clicked, dismiss the dialog */
                if (v == okButton)
                        dismiss();
        }

}



quickfind.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"

    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Vpišite iskani niz:" />
    <AutoCompleteTextView android:id="@+id/autocomplete_country"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"/>


 <Button android:id="@+id/close"
    android:layout_width="150px"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="@string/title_close"
    android:layout_marginTop = "50px"
    android:layout_gravity ="center"
    />
   </LinearLayout>


and list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp"
    android:textColor="#000">
</TextView>



Later, when the errors are gone, the countries list will be replaced
with data  from json webservice. I'm a beginner in java..


P.S.
Sorry for mistakes in my English



Regards,
Tadej




-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to