当我按下购物车按钮时,我的应用程序崩溃。以下是我的Android应用程序的购物车代码。
> 05-02 21:27:21.970 7698-7698/com.example.admin.clicknorder
> E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache 05-02
> 21:27:21.970 7698-7698/com.example.admin.clicknorder E/OpenGLRenderer:
> MAX_TEXTURE_SIZE: 16384 05-02 21:27:21.970
> 7698-7698/com.example.admin.clicknorder E/OpenGLRenderer: Getting
> MAX_TEXTURE_SIZE from Caches::initConstraints() 05-02 21:27:21.970
> 7698-7698/com.example.admin.clicknorder E/OpenGLRenderer:
> MAX_TEXTURE_SIZE: 16384 05-02 21:27:49.030
> 7698-7698/com.example.admin.clicknorder E/dalvikvm: Could not find
> class 'android.graphics.drawable.RippleDrawable', referenced from
> method
> android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
> 05-02 21:28:02.138 7698-7698/com.example.admin.clicknorder
> E/AndroidRuntime: FATAL EXCEPTION: main
> Process: com.example.admin.clicknorder, PID: 7698
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.example.admin.clicknorder/com.example.admin.clicknorder.Cart}:
> android.view.InflateException: Binary XML file line #11: Error
> inflating class android.support.v7.app.AlertController.RecycleListView
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
> at android.app.ActivityThread.access$800(ActivityThread.java:135)
> at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:136)
> at android.app.ActivityThread.main(ActivityThread.java:5001)
> 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:793)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: android.view.InflateException: Binary XML file line #11:
> Error inflating class
> android.support.v7.app.AlertController.RecycleListView
> at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
> at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
> at
> android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
> at
> android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
> at com.example.admin.clicknorder.Cart.onCreate(Cart.java:46)
> at android.app.Activity.performCreate(Activity.java:5231)
> at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
> at android.app.ActivityThread.access$800(ActivityThread.java:135)
> at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:136)
> at android.app.ActivityThread.main(ActivityThread.java:5001)
> 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:793)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: java.lang.ClassNotFoundException: Didn't find class
> "android.support.v7.app.AlertController.RecycleListView" on path:
> DexPathList[[zip file
> "/data/app/com.example.admin.clicknorder-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.admin.clicknorder-2,
> /system/lib]]
> at
> dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
> at android.view.LayoutInflater.createView(LayoutInflater.java:559)
> at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
> at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
> at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
> at
> android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
> at
> android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
> at com.example.admin.clicknorder.Cart.onCreate(Cart.java:46)
> at android.app.Activity.performCreate(Activity.java:5231)
> at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
> at android.app.ActivityThread.access$800(ActivityThread.java:135)
> at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:136)
> at android.app.ActivityThread.main(ActivityThread.java:5001)
> 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:793)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
> at dalvik.system.NativeStart.main(Native Method)
这是调试报告
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:background="@drawable/background"
tools:context="com.example.admin.clicknorder.Cart">
<android.support.v7.app.AlertController.RecycleListView
android:id="@+id/listCart"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v7.widget.CardView
android:layout_alignParentBottom="true"
app:cardBackgroundColor="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="100dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_margin="8dp"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="Total:"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/total"
android:text="Rs 1000"
android:textSize="20sp"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<info.hoang8f.widget.FButton
android:id="@+id/btnPlaceOrder"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:text="Place Order"
android:textColor="@android:color/holo_red_dark"
app:buttonColor="@color/btnSignActive"
app:cornerRadius="4dp"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
android:layout_marginTop="40dp"
android:layout_below="@+id/linearLayout2"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
最后这里是购物车活动xml代码
SELECT
B.ID, B.ForeignKeyId, A.PrimaryKeyId
FROM
B
LEFT OUTER JOIN
A ON A.PrimaryKeyId = B.ForeignKeyId
WHERE
A.PrimaryKeyId IS NULL
答案 0 :(得分:3)
在你的布局中使用
<android.support.v7.app.AlertController.RecycleListView
但在您的代码中使用
RecyclerView
两个人和我的朋友都不一样。
答案 1 :(得分:1)
def mys(x):
result = []
for i in range(2,x):
r = x % i
if r == 0:
result.append(i)
return result
x = input("Enter a number: ")
print(mys(x))
是一个内部类,无法供外部使用。
更改
RecycleListView
到
android.support.v7.app.AlertController.RecycleListView