我创建了一个包含EditTextfields和一个CustomAutoCompletField的注册表单,该表单用于自动填充地点,这些地方将从google places api收到。在我实现此AutoCompleteTextView之前,图形布局预览工作正常。
这里是我总是得到的错误消息:
Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'editTextStyle' in current theme
Failed to find style 'autoCompleteTextViewStyle' in current theme
Failed to find style 'buttonStyle' in current theme
Failed to find style 'textViewStyle' in current theme
Couldn't resolve resource @string/EditText_firstname
Couldn't resolve resource @string/EditText_lastname
Couldn't resolve resource @string/EditText_username
Couldn't resolve resource @string/EditText_email
Couldn't resolve resource @string/EditText_password
Couldn't resolve resource @string/EditText_residence
Couldn't resolve resource @string/btn_register
Couldn't resolve resource @string/login
这里是布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:orientation="vertical"
android:padding="10dip"
tools:context=".RegisterActivity" >
<EditText
android:id="@+id/fname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
android:drawableLeft="@drawable/user"
android:drawablePadding="10dip"
android:hint="@string/EditText_firstname"
android:textSize="20sp" />
<EditText
android:id="@+id/lname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
android:drawableLeft="@drawable/user"
android:drawablePadding="10dip"
android:hint="@string/EditText_lastname"
android:textSize="20sp" />
<EditText
android:id="@+id/uname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
android:drawableLeft="@drawable/user"
android:drawablePadding="10dip"
android:ems="10"
android:hint="@string/EditText_username"
android:textSize="20sp" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
android:drawableLeft="@drawable/email"
android:drawablePadding="10dip"
android:hint="@string/EditText_email"
android:inputType="textEmailAddress"
android:textSize="20sp" />
<EditText
android:id="@+id/pword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
android:drawableLeft="@drawable/password"
android:drawablePadding="10dip"
android:hint="@string/EditText_password"
android:inputType="textPassword"
android:textSize="20sp" />
<com.autocomplete.CustomAutoCompleteTextView
android:id="@+id/atv_places"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/EditText_residence" />
<Button
android:id="@+id/register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:text="@string/btn_register"
android:textSize="20sp" />
<TextView
android:id="@+id/bktologin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="@string/login"
android:textColor="@color/white" />
<TextView
android:id="@+id/register_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
这里是CustomAutoCompleteTextView Java类:
/** Customizing AutoCompleteTextView to return Place Description
* corresponding to the selected item
*/
public class CustomAutoCompleteTextView extends AutoCompleteTextView {
public CustomAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/** Returns the place description corresponding to the selected item */
@Override
protected CharSequence convertSelectionToString(Object selectedItem) {
/** Each item in the autocompetetextview suggestion list is a hashmap object */
HashMap<String, String> hm = (HashMap<String, String>) selectedItem;
return hm.get("description");
}
}
还有我的主题定义:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">#5C5C5C</item>
<item name="android:textSize">14sp</item>
<item name="android:padding">0dp</item>
</style>
</resources>