我已经创建了on edittext addTextChangedListener。如果我在onTextChanged期间单击编辑文本。两个布局将被隐藏,并且asyntask将被调用。第一次所有这些功能都将正常工作。如果单击编辑文本第二次应用程序崩溃。
logcat的:
FATAL EXCEPTION: main Process: com.abservetech.jobstar, PID: 24942
android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x101009b a=1}
at android.content.res.Resources.loadColorStateList(Resources.java:2330)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:65)
at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:45)
at android.widget.Editor$SuggestionsPopupWindow$SuggestionInfo.<init>(Editor.java:2431)
at android.widget.Editor$SuggestionsPopupWindow$SuggestionInfo.<init>(Editor.java:2426)
at android.widget.Editor$SuggestionsPopupWindow.initContentView(Editor.java:2414)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2237)
at android.widget.Editor$SuggestionsPopupWindow.<init>(Editor.java:2372)
at android.widget.Editor.showSuggestions(Editor.java:1727)
at android.widget.Editor$1.run(Editor.java:1629)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5401)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:970)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)
at dalvik.system.NativeStart.main(Native Method)
CODE:
searchkey.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hidelayout.setVisibility(View.GONE);
searchlist.setVisibility(View.VISIBLE);
}
});
searchkey.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
headline = s.toString();
new searchkillskill().execute(headline);
hidelayout.setVisibility(View.GONE);
searchlist.setVisibility(View.VISIBLE);
}
@Override
public void afterTextChanged(Editable s) {
}
});
xml编码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.abservetech.jobstar.WorkExperience">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:padding="10dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:theme="@style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/searchkey"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/Keyskills_Designations"
android:textColorHint="@color/colorPrimary"
android:textSize="15sp" />
</android.support.design.widget.TextInputLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="10dp">
<View
android:id="@+id/view_cnfpassword"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#aaaaaa" />
<View
android:id="@+id/second_view_cnfpassword"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF9800"
android:visibility="invisible" />
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/hidelayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout5"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/linearLayout5"
android:text="@string/Location"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="20dp" />
<Spinner
android:id="@+id/hslocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<AutoCompleteTextView
android:id="@+id/autocompletsearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/grey"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:singleLine="true"
android:layout_toLeftOf="@+id/cancel"
android:layout_toRightOf="@+id/back"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:layout_weight=".5"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/textView57"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout5"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/linearLayout5"
android:text="@string/Experience"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="@+id/hsexperience"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".5" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="25dp"
android:layout_toEndOf="@+id/linearLayout5"
android:layout_toRightOf="@+id/linearLayout5"
android:layout_weight=".5"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/textView59"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout5"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/linearLayout5"
android:text="@string/salary"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="@+id/hssalary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/searchjobs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView49"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:background="@color/colorPrimary"
android:text="@string/SearchJobs"
android:textColor="@color/white" />
</LinearLayout>
<ListView
android:id="@+id/homesearchlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:0)
大多数情况下会出现此错误,因为主题配置不正确,尝试使用应用程序的默认主题,然后像现在一样运行应用程序。它可能适合你。