乐学成语收藏遇到的问题

xiaoxiao2021-02-28  96

06/07 20:05:34: Launching app Cold swapped changes. $ adb shell am start -n "com.example.bz0209.happyidiom/com.example.bz0209.happyidiom.activity.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Client not ready yet..Connected to process 3197 on device Nexus_5_API_24 [emulator-5554] W/System: ClassLoader referenced unknown path: /data/app/com.example.bz0209.happyidiom-1/lib/x86 I/InstantRun: Instant Run Runtime started. Android package is com.example.bz0209.happyidiom, real application class is null. W/System: ClassLoader referenced unknown path: /data/app/com.example.bz0209.happyidiom-1/lib/x86 W/gralloc_ranchu: Gralloc pipe failed                   [ 06-07 12:05:37.421  3197: 3197 D/         ]                   HostConnection::get() New Host Connection established 0xaa7ce480, tid 3197                   [ 06-07 12:05:37.464  3197: 3218 D/         ]                   HostConnection::get() New Host Connection established 0xaa7cee00, tid 3218 I/OpenGLRenderer: Initialized EGL, version 1.4 D/OpenGLRenderer: Swap behavior 1 W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.example.bz0209.happyidiom/databases/collect.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main                   Process: com.example.bz0209.happyidiom, PID: 3197                   java.lang.IllegalStateException : You need to use a Theme.AppCompat theme (or descendant) with this activity.                       at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:355)                       at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:324)                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:285)                       at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:83)                       at android.support.v7.app.AlertController.installContent(AlertController.java:225)                       at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)                       at android.app.Dialog.dispatchOnCreate(Dialog.java:389)                       at android.app.Dialog.show(Dialog.java:293)                       at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:955)                       at com.example.bz0209.happyidiom.adapter.CollectAdapter$1.onClick(CollectAdapter.java:68)                       at android.view.View.performClick(View.java:5610)                       at android.view.View$PerformClick.run(View.java:22260)                       at android.os.Handler.handleCallback(Handler.java:751)                       at android.os.Handler.dispatchMessage(Handler.java:95)                       at android.os.Looper.loop(Looper.java:154)                       at android.app.ActivityThread.main(ActivityThread.java:6077)                       at java.lang.reflect.Method.invoke(Native Method)                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Application terminated.

package com.example.bz0209.happyidiom.adapter; import android.content.Context; import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import com.example.bz0209.happyidiom.R; import com.example.bz0209.happyidiom.dao.CollectDao; import com.example.bz0209.happyidiom.entity.Animal; import java.util.ArrayList; import java.util.List; /** * Created by Administrator on 2017/5/26. */ public class CollectAdapter extends ArrayAdapter<Animal> { private int resourceID; private List<Animal> list = new ArrayList<Animal>(); //private List<Animal> list; private Context context; private CollectDao collectDao; public CollectAdapter(Context context, int resource, List<Animal> objects,CollectDao collectDao) { super(context, resource, objects); //this.context=context; resourceID=resource; list=objects; this.collectDao=collectDao; } @Override public View getView(int position, View convertView, ViewGroup parent) { final Animal animal=getItem(position); //final Animal a=list.get(position); //collectDao=new CollectDao(context); View view; ViewHolder viewHolder; if(convertView==null){ view= LayoutInflater.from(getContext()).inflate(resourceID,null); viewHolder=new ViewHolder(); viewHolder.btnDel=(ImageButton)view.findViewById(R.id.btnDel); viewHolder.tvName=(TextView)view.findViewById(R.id.tvName); view.setTag(viewHolder); viewHolder.btnDel.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ AlertDialog.Builder builder=new AlertDialog.Builder(getContext()); builder.setTitle("确定要删除吗"); builder.setPositiveButton("确定",new android.content.DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialogInterface, int which){ list.remove(animal); collectDao.DeleteData(animal.getId()); //list.clear(); //collectDao.QueryData(list); notifyDataSetChanged(); } //android.content.DialogInterface.OnClickListener listener= }); builder.setNeutralButton("取消",null); builder.show(); } }); }else{ view=convertView; viewHolder= (ViewHolder) view.getTag(); } viewHolder.tvName.setText(animal.getName()); return view; } class ViewHolder{ TextView tvName; ImageButton btnDel; } }

解决办法--

包倒错了 导入了不是此Activity的方法或属性

转载请注明原文地址: https://www.6miu.com/read-60970.html

最新回复(0)