AutoCompleteText inside Dialog, inside Menu

Put your problem here if it does not fit any of the other categories.

AutoCompleteText inside Dialog, inside Menu

Postby svebee » Fri Apr 30, 2010 9:25 pm

I have the menu.xml file

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <menu xmlns:android="http://schemas.android.com/apk/res/android">
  2.  
  3.     <item android:title="@string/prikaziLiniju" android:id="@+id/linija"/>
  4.  
  5. </menu>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


and I have

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     /* Creates the menu items */
  2.  
  3.     public boolean onCreateOptionsMenu(Menu menu) {
  4.  
  5.         MenuInflater inflater = getMenuInflater();
  6.  
  7.         inflater.inflate(R.menu.menu, menu);
  8.  
  9.         return true;
  10.  
  11.     }
  12.  
  13.      
  14.  
  15.     /* Handles item selections */
  16.  
  17.     public boolean onOptionsItemSelected(MenuItem item) {
  18.  
  19.         switch (item.getItemId()) {
  20.  
  21.         case R.id.linija:
  22.  
  23.                 Dialog dialog = new Dialog(this);
  24.  
  25.             dialog.setContentView(R.layout.popup);
  26.  
  27.             dialog.setTitle("Location");
  28.  
  29.             dialog.show();
  30.  
  31.             return true;
  32.  
  33.         }
  34.  
  35.         return false;
  36.  
  37.     }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


and

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         static final String[] STANICE = new String[] {
  2.  
  3.                 "LocationA",
  4.  
  5.                 "Something else",
  6.  
  7.                 "LocationC",               
  8.  
  9.                  };
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


inside MapActivity and before

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     public void onCreate(Bundle savedInstanceState) {
  2.  
  3.         super.onCreate(savedInstanceState);
  4.  
  5.         setContentView(R.layout.karta);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


popup.xml is this

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    android:scrollbars="vertical" android:scrollbarStyle="insideOverlay"
  12.  
  13. >
  14.  
  15. <AutoCompleteTextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5sp" android:layout_marginRight="5sp" android:id="@+id/autocomplete_stanicaKraj"/>
  16.  
  17. <Button android:layout_height="wrap_content" android:id="@+id/btn" android:layout_width="fill_parent" android:layout_gravity="center" android:layout_marginLeft="50sp" android:layout_marginRight="50sp" android:text="@string/ok"></Button>
  18.  
  19. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Basically, I have menu, when I click on the item I get dialog, inside dialog is AutoComplete text...which isn't working... I tried to put (as in the other file, and it works) somewhere this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   final AutoCompleteTextView textView2 = (AutoCompleteTextView) findViewById(R.id.autocomplete_stanicaKraj);
  2.  
  3.   ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, R.layout.list_item, STANICE);
  4.  
  5.   textView2.setAdapter(adapter2);
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


to get the list but it's not working :?

and I want (as in the other file, and it works) to put button (which is already there - OK button) and do this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   Button btn=(Button)findViewById(R.id.btn);
  2.  
  3.   btn.setOnClickListener(new View.OnClickListener() {
  4.  
  5.          
  6.  
  7.          public void onClick(View v) {
  8.  
  9.               somethingString = (String) textView2.getText().toString();
  10.  
  11.                   Intent i = new Intent(Karta.this, Stanica.class);
  12.  
  13.               Bundle b = new Bundle();
  14.  
  15.               b.putString("KEY", somethingStringValue);
  16.  
  17.               i.putExtras(b);
  18.  
  19.               startActivity(i);
  20.  
  21.          }
  22.  
  23.     });
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


how to realize this? this structure

MapActivity -> Menu -> Dialog -> AutoCompleteText field + OnClickListener button

Thank you :)
svebee
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Apr 21, 2010 10:19 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests