我正在一個NoSuchMethodError
帶班,我把它擴展了TextView
。我做的唯一的事情就是添加一些變量並添加onLongClickListener
。沒有更多的修改。獲取的NoSuchMethodError與TextView的方法
當我在我的android手機中使用我的應用程序時,一切工作正常4.1.2 但在我的朋友的手機是4.0.3,它會拋出此NoSuchMethodError
。
下面是代碼當我創建擴展的TextView類:
descrip=new TextViewList(context, admin, this);
descrip.setPadding(0, 15, 0, 15);
descrip.setGravity(Gravity.CENTER);
descrip.setTextAlignment(Gravity.CENTER);
descrip.setText(c.getString(c.getColumnIndex("Descripcion")));
descrip.setTag(c.getString(c.getColumnIndex("ID")));
descrip.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
descrip.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
descrip.setBackground(img);
layDescripcion.addView(descrip);
首先,它引發異常與setTextAlignment
,然後我刪除,並與該setBackground
方法再次把它。
什麼是造成此錯誤?這是否意味着我的應用程序與4.1.2以下版本的Android 版本不兼容?創建項目時,我將minimun設置爲2.2。我在使用android.support.v4庫的地方請求。
這裏是logcat的:
07-09 21:45:26.715: E/AndroidRuntime(13481): FATAL EXCEPTION: main
07-09 21:45:26.715: E/AndroidRuntime(13481): java.lang.NoSuchMethodError: modelo.TextViewList.setBackground
07-09 21:45:26.715: E/AndroidRuntime(13481): at modelo.ListaTextViewList.mostrarGastos(ListaTextViewList.java:92)
07-09 21:45:26.715: E/AndroidRuntime(13481): at controlador.AdminUI.establecerListaGastoVar(AdminUI.java:138)
07-09 21:45:26.715: E/AndroidRuntime(13481): at com.ConApps.walletsaver.GastosVariables.onCreate(GastosVariables.java:23)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.Activity.performCreate(Activity.java:4465)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.ActivityThread.access$600(ActivityThread.java:127)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.os.Looper.loop(Looper.java:137)
07-09 21:45:26.715: E/AndroidRuntime(13481): at android.app.ActivityThread.main(ActivityThread.java:4507)
07-09 21:45:26.715: E/AndroidRuntime(13481): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 21:45:26.715: E/AndroidRuntime(13481): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 21:45:26.715: E/AndroidRuntime(13481): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
07-09 21:45:26.715: E/AndroidRuntime(13481): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
07-09 21:45:26.715: E/AndroidRuntime(13481): at dalvik.system.NativeStart.main(Native Method)
http://developer.android.com/reference/android/小部件/ TextView.html。支票方法支持 – Raghunandan
看到我的答案哥們。 – Unknown