[android-developers] Re: Autocomplete with suggestions in Custom Dialog

2010-08-11 Thread viktor
This code: ArrayAdapterString adapter = new
ArrayAdapterString(this, R.layout.list_item, COUNTRIES);

Be carefully, if you use autocomplete in Dialog, you should passing
Context as 1st arg of constructor, ArrayAdapterT(Context,
R.layout.list_item, COUNTRIES)()

Please read Java Code Style, How did you compile your code, your class
name is wrong (quickfind -- Quickfind).

On 11 Сер, 14:58, titleist tadej.ore...@gmail.com wrote:
 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);
                     ArrayAdapterString adapter = new 
 ArrayAdapterString(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 ArrayAdapterString(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);
                     ArrayAdapterString adapter = new 
 ArrayAdapterString(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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Autocomplete with suggestions in Custom Dialog

2010-08-11 Thread titleist
Thanks, my quickfind now works. I will correct names in my
appplication, it will even look better :)


Regards,
Tadej

On 11 avg., 19:27, viktor victor.scherb...@gmail.com wrote:
 This code: ArrayAdapterString adapter = new
 ArrayAdapterString(this, R.layout.list_item, COUNTRIES);

 Be carefully, if you use autocomplete in Dialog, you should passing
 Context as 1st arg of constructor, ArrayAdapterT(Context,
 R.layout.list_item, COUNTRIES)()

 Please read Java Code Style, How did you compile your code, your class
 name is wrong (quickfind -- Quickfind).

 On 11 Сер, 14:58, titleist tadej.ore...@gmail.com wrote:



  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);
                      ArrayAdapterString adapter = new 
  ArrayAdapterString(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 ArrayAdapterString(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);
                      ArrayAdapterString adapter = new 
  ArrayAdapterString(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- Skrij navedeno besedilo -

 - Prikaži citirano besedilo -

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to