actvDivName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
try{
String str = actvDivName.getText().toString();
if(b){
actvPType.setText("");
}
else{
for (int i=0;i<QRDivArrayAdapter.getCount();i++)
{
String temp = QRDivArrayAdapter.getItem(i).toString();
if (str.compareTo(temp) == 0){
return;
}
}
actvDivName.setText("");
}
}catch(Exception focusfordivision)
{
Log.d("eEmp/Resume", "Error raised due to " + focusfordivision.toString());
}
}
});
actvEntryCategory.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
String str = actvEntryCategory.getText().toString();
if(b)
{
actvDivName.setText("");
actvPType.setText("");
}
else
{
for (int i=0;i<EntryTypeAdapter.getCount();i++)
{
String temp = EntryTypeAdapter.getItem(i).toString();
if (str.compareTo(temp) == 0){
return;
}
}
actvEntryCategory.setText("");
}
// actvEntryCategory.setError("Please select valid Entry Type");
}
});
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<LinearLayout
android:id="@+id/LLPlaceDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.CardView
android:id="@+id/zone_card_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_custom_margin"
android:layout_marginRight="@dimen/activity_custom_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_weight="0.54"
card_view:cardElevation="@dimen/cardview_default_elevation"
card_view:contentPadding="10dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_zone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1">
<com.efftronics.android.eEmployee.Common.UI.CustomAutoCompleteTextView
android:id="@+id/actventry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="11"
android:hint="@string/Entry_Type"
android:inputType="textCapWords|textMultiLine"
android:maxLength="250"
android:theme="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_Division"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1">
<com.efftronics.android.eEmployee.Common.UI.CustomAutoCompleteTextView
android:id="@+id/actventryDivName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/station"
android:inputType="textCapWords|textMultiLine"
android:maxLength="250"
app:hintTextAppearance="@style/AutocompleteTheme"
/>
</android.support.design.widget.TextInputLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_ProductType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1">
<com.efftronics.android.eEmployee.Common.UI.CustomAutoCompleteTextView
android:id="@+id/actvProductType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/product_type"
android:inputType="textCapWords|textMultiLine"
android:maxLength="250"
app:hintTextAppearance="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1" android:baselineAligned="false">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_FromDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.4">
<EditText
android:id="@+id/edtFromDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:inputType="date"
android:hint="@string/from_date"
android:textColor="@android:color/black"
android:theme="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_FromTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.6">
<EditText
android:id="@+id/edtFromTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:inputType="none"
android:hint="@string/from_time"
android:textColor="@android:color/black"
android:theme="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1" android:baselineAligned="false">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_toDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.4">
<EditText
android:id="@+id/edtToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:inputType="date"
android:hint="@string/to_date"
android:textColor="@android:color/black"
android:theme="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_toTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="0.6">
<EditText
android:id="@+id/edtToTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:inputType="none"
android:hint="@string/to_time"
android:textColor="@android:color/black"
android:theme="@style/AutocompleteTheme" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</TableRow>
actventry
,actventryDivName
,actvProductType
在xml文件中有三个CustomAutoCompleteTextViews
。
该方法适用于actventry
但不适用于actventryDivName
和actvProductType
。
actvDivName
和actvEntryCategory
是CustomAutoCompleteTextViews
。同样,我也写了这个方法来保留一个CustomAutoCompleteTextView
。
我的布局中有三个CustomAutoCompleteTextView
,但此方法仅针对第一个CustomAutoCompleteTextView
调用,而不是针对其余两个调用。
我犯了什么错误?我是android的新手。