In my android I have the xml file :-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/liner" >
<EditText
android:id="@+id/user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<EditText
android:id="@+id/partner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<EditText
android:id="@+id/home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
</LinearLayout>
Now I have a string i.e String field =error.getmethod(); This string(field) may return user/name/partner/home.. I want to set error message according to edittext fields with their id's..I have done
ViewGroup edittextviews = (ViewGroup) findViewById(R.id.liner);
for(int i=0; i < edittextviews.getChildCount(); i++) {
View childView = edittextviews.getChildAt(i);
if(childView.getText().toString()==field ){
childView.setError("here is an error");
}
}
But it is showing error...where is the problem???