- mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml
- select the galatea archetype
- specify your groupId, artifactId and version. In my case, I chose 'org.eoti.galatea', 'AutoComplete' and '1.0-SNAPSHOT'.
- Make sure your emulator is running... In my case, that was 'emulator -avd Device1'
- Change into your new directory (whatever your artifactId name was) and do a 'mvn clean install'
Now, we are going to modify our project as per this tutorial.
In src/main/android/layout create an li.xml file:
<?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>
Now, replace src/main/android/layout/main.xml:<?xml version="1.0" encoding="utf-8"?>Open MyActivity.java and add these lines into the end of the onCreate method:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Country" />
<AutoCompleteTextView android:id="@+id/autocomplete_country"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
Open src/main/android/res/values/strings.xml and add this inside the resources tag:AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
String[] countries = getResources().getStringArray(R.array.countries_array);
ArrayAdapteradapter = new ArrayAdapter (this, R.layout.li, countries);
textView.setAdapter(adapter);
<string-array name="countries_array">Redeploy (mvn clean install) and launch the app. Start typing. If you type either a 'ba' or 'be' you will see a small subset of options.
<item>Bahrain</item>
<item>Bangladesh</item>
<item>Barbados</item>
<item>Belarus</item>
<item>Belgium</item>
<item>Belize</item>
<item>Benin</item>
</string-array>
No comments:
Post a Comment