I'm new in Android and I've got 2 questions.
First, the idea is to have the AutoCompleteTextView items in XML format other than String Array.
Using java Syntax Highlighting
- String[] Animals = new String[] {
- "Cat", "Dog", ...
- };
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Is there a way how can I populate the ArrayAdapter using an XML formatted items somewhat like
this.
Using xml Syntax Highlighting
- <resources>
- <array name="Animals">
- <item>Cat</item>
- <item>Dog</item>
- <item>...</item>
- </array>
- </resources>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
I know that this format works in ListView but how could I achieve like this in AutoCompleteTextView.
Second, when a user choose and click(using the Center Button) from the AutoCompleteTextView the user will be redirect in a separate layout. So far this two doesn't work in me and I don't have any idea how I can redirect the user to view other layout?
Using java Syntax Highlighting
- textView.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
- long arg3) {
- if( textView.getText().toString().equals("Dog") ) {
- // seperate layout view
- //Image of a Dog
- }
- }
- });
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Or
Using java Syntax Highlighting
- textView.setOnItemSelectedListener( new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> arg0, View arg1,
- int arg2, long arg3) {
- if( textView.getText().toString().equals("Dog") ) {
- // seperate layout view
- //Image of a Dog
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
- // TODO Auto-generated method stub
- }
- });
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
If the condition was meet then it should redirect the user from another layout somewhat like this:
Using xml Syntax Highlighting
- <ImageView
- android:src="@drawable/Dog.jpg"
- android:layout_width="wrap_content" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Hoping someone can help me.
Thanks in advance and more power to the Anddev Community.




