我正在创建注册活动,并在其布局中“合并 address_from_merge”-layout,但在运行时 setError() 无法在合并布局中的任何 EditText 上工作,即没有得到验证,而是在当前布局中的其他 EditText 上工作.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/back"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
<!--
Notice that widget sizes are expressed in dip, or device-independent
pixels, while text sizes are expressed in sp, or scale-independent pixels,
to factor in user-chosen font sizes.
-->
<FrameLayout
android:id="@+id/image_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/image_container" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/login" />
<TextView
android:id="@+id/totPrdItems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign Up..."
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<EditText
android:id="@+id/usernm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="User Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/emailId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="EmailId: abc123@xyz.com"
android:inputType="textEmailAddress" >
</EditText>
<EditText
android:id="@+id/pwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" >
</EditText>
<EditText
android:id="@+id/repwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Confirm Password"
android:inputType="textPassword" >
</EditText>
<EditText
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Mob.No."
android:inputType="phone" />
<include layout="@layout/address_from_merge" />
<TextView
android:id="@+id/info_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dip"
android:text="Tapping Singup You agree to Terms of Service and Privacy Policy"
android:textColor="@android:color/background_light"
android:textSize="10sp" />
<Button
android:id="@+id/signUp"
android:onClick="action_signUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign Up" >
</Button>
</TableLayout>
</FrameLayout>
<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dip"
android:shadowColor="@android:color/background_light"
android:shadowDx="1.0"
android:shadowDy="1.0"
android:shadowRadius="1"
android:text="Already have an account?"
android:textColor="@android:color/background_light"
android:textSize="18sp" />
<Button
android:id="@+id/signIn_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="goto_signIn"
android:text="Sign In >>"
android:textSize="24sp" />
<Button
android:id="@+id/btn_forgotPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="goto_forgotPwd"
android:text="Forgot Password"
android:textSize="24sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
and layout of "address_from_merge"(<include layout="@layout/address_from_merge" />)
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="1" android:shrinkColumns="0">
<View android:layout_width="fill_parent" android:layout_height="4sp" />
<EditText
android:id="@+id/add_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:ems="10"
android:singleLine="false"
android:inputType="textPostalAddress"
android:hint="Address">
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Country :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/add_country"
android:text="--Select Country--"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="@array/Country"
android:hint="Country" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/add_state"
android:text="--Select State--"
android:entries="@array/State"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="State" />
<EditText
android:hint="City"
android:id="@+id/add_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
<EditText
android:hint="Zip Code"
android:id="@+id/add_zipCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" />
</merge>