gpt4 book ai didi

android - 可搜索微调器使我的应用程序在多任务处理时崩溃

转载 作者:行者123 更新时间:2023-11-29 01:16:26 26 4
gpt4 key购买 nike

我在图书馆工作 Searchable Spinner ,但是如果我在打开微调器时按下 android 主页按钮或多任务按钮,应用程序会崩溃并在屏幕上打印:“不幸的是,Appname 已停止。”

我的 fragment Activity :

public class buscadorFragment extends Fragment implements View.OnClickListener {


public Button BotonRecargar;
public IndeterminateRoadRunner UCargando;
public TextView TextoPrueba;
public TextView TextoError;


private OnFragmentInteractionListener mListener;

public SearchableSpinner SpCateg;
public SearchableSpinner SpUbic;

String[] CategoriasArray = {"Categorias"};
String[] UbicacionesArray ={"Ubicaciones"};

ArrayAdapter<String> CatspinnerAdapter;
ArrayAdapter<String> UbicspinnerAdapter;



public buscadorFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_buscador, container, false);
CatspinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, CategoriasArray);
CatspinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
SpCateg.setAdapter(CatspinnerAdapter);
CatspinnerAdapter.notifyDataSetChanged();


UbicspinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, UbicacionesArray);
UbicspinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
SpUbic.setAdapter(UbicspinnerAdapter);
UbicspinnerAdapter.notifyDataSetChanged();



SpCateg.setTitle("Categoría");
SpCateg.setPositiveButton("Cancelar");

SpUbic.setTitle("Ubicación");
SpUbic.setPositiveButton("Cancelar");

return view;
}

我的 fragment 布局:

只添加

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">

<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/Category_Spinner" />

<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/Ubication_Spinner" />


</LinearLayout>

有 logcat:

08-31 20:09:21.656 18172-18172/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kreativer.upy, PID: 18172
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.toptoche.searchablespinnerlibrary.SearchableSpinner)
at android.os.Parcel.writeSerializable(Parcel.java:1323)
at android.os.Parcel.writeValue(Parcel.java:1271)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.FragmentState.writeToParcel(Fragment.java:133)
at android.os.Parcel.writeTypedArray(Parcel.java:1140)
at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373)
at android.os.Parcel.writeParcelable(Parcel.java:1292)
at android.os.Parcel.writeValue(Parcel.java:1211)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2643)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3252)
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:5426)
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:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.NotSerializableException: android.widget.ArrayAdapter
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1366)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1673)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1519)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1483)
at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:981)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1076)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1406)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1673)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1519)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1483)
at android.os.Parcel.writeSerializable(Parcel.java:1318)
at android.os.Parcel.writeValue(Parcel.java:1271) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618) 
at android.os.Bundle.writeToParcel(Bundle.java:1692) 
at android.os.Parcel.writeBundle(Parcel.java:643) 
at android.app.FragmentState.writeToParcel(Fragment.java:133) 
at android.os.Parcel.writeTypedArray(Parcel.java:1140) 
at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373) 
at android.os.Parcel.writeParcelable(Parcel.java:1292) 
at android.os.Parcel.writeValue(Parcel.java:1211) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618) 
at android.os.Bundle.writeToParcel(Bundle.java:1692) 
at android.os.Parcel.writeBundle(Parcel.java:643) 
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2643) 
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3252) 
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:5426) 
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:1268) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
at dalvik.system.NativeStart.main(Native Method) 

仅当微调器打开时崩溃,否则应用程序继续运行。我是新手,想学习,所以在此先感谢。

最佳答案

看起来这是库的问题,因为其他用户在 Github 上报告了同样的问题。要解决此问题,您可以关闭 onPause() 方法中的 searchableListDialog。

于是在SearchableListDialog.java中编写如下代码

@Override
public void onPause()
{
super.onPause();
dismiss();
}

关于android - 可搜索微调器使我的应用程序在多任务处理时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39261508/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com