1. 程式人生 > >[已解決] Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a n

[已解決] Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a n

.androidstudio.cartdemo, PID: 12678
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.AbsListView.obtainView(AbsListView.java:2363)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.ListView.measureHeightOfChildren(ListView.java:1270)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.ListView.onMeasure(ListView.java:1182)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.View.measure(View.java:17565)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2045)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1196)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1409)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:580)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:550)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5343)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)

05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

原因分析:

ListView 的getView 方法裡面返回的為空了,檢查一下返回的view 就可以了

相關推薦

[解決]Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()'

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportant

[解決] Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a n

.androidstudio.cartdemo, PID: 12678 05-29 11:45:24.014 12678-12678/tech.androidstudio.cartdemo E/AndroidRuntime: java.lang.NullPointerExc

RN問題java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getId()'

錯誤資訊: java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.view.View.getId()’ on a null object reference j

[解決]: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4

今天開發的時候,發現明明有這個id,而且也通過findviewbyid獲取了,但是為什麼最後得到viewpager 是空呢? Caused by: java.lang.NullPointerException: Attempt to invoke virtual metho

Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setAlpha(int)' on a null o

1.寫在前面 給background設定透明度時總是報這個錯,如圖 2.解決 原來getBackground().setAlpha(0);方法沒問題,是控制元件或者佈局並沒有background這個屬性,加上就沒問題了

Android異常:java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.len

Android studio 異常:java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object refere

【未解決】java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitm

接應用寶sdk,在支付時 Bitmap bmp = BitmapFactory.decodeResource(mMainActivity.getResources(), R.drawable.sample_yuanbao);                ByteArray

@BindView問題 Attempt to invoke virtual method 'void android ...' on a null object reference

Caused by:java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.Toolbar.setNavigationIcon(int)

子執行緒Handler.sendMessage 報錯:Attempt to invoke virtual method 'boolean android.os.Handler.sendMessage

03-17 08:10:18.760 16029-16029/tech.androidstudio.tulingdemo E/AndroidRuntime: FATAL EXCEPTION: main 03-17 08:10:18.760 16029-16029/tech.

Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerViewLayoutManager.onMeasur

RecycleView空指標異常 錯誤程式碼如下:java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v7.widget.Recycler

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Intent.getI...

這個報錯比較騷,完全只是因為Intent沒有寫好而已,下面是錯誤的寫法(最好不要在方法外賦值): 進入本活動時即刻報錯:

Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference

tac perf cti pla invoke one spa n) null 【Android】getActionBar()為null的解決方法總結 setContentView(R.layout.activity_main);android.support.v7.app

Binary XML file line #19: Attempt to invoke virtual method 'boolean java.lang.String.equals(java....

APP中需要實現LayoutInflater佈局載入器動態載入佈局,然而開啟程式一執行就閃退。。。

Attempt to invoke virtual method 'void android.widget.TextView.setText錯誤

整了接近一個小時的錯誤,有時候不能僅僅因為AS的報錯就跟著報錯語句zhao找原因,有時候可能因為隨著一個Activity的增多,導致很多長得相似(比如userName,user_name,tv_userName,tv_user_name),此時你找到的id並不是對應介面所具有的id,也就是說是別的介

子執行緒Handler sendMessage 報錯 Attempt to invoke virtual method '

                03-17 08:10:18.760 16029-16029/tech.androidstudio.tulingdemo E/AndroidRuntime: FATAL EXCEPTION: main03-17 08:10:18.760 16029-16029/tech.and

Attempt to invoke virtual method 'void java.lang.reflect.Field.setAccessible(boolean)' on a null obj

具體報錯 使用android自帶的頂部導航欄TabLayout時需要設定底部橫條的寬度,這就需要通過反射來修改TabLayout,網上也是有很多文章來介紹如何實現,這裡也貼出一種實現方式 public class TabLayoutIndicatorUt

報錯Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)'

問題:Caused by: android.view.InflateException: Binary XML file line #11: Attempt to invoke virtual met

Binary XML file line #19: Attempt to invoke virtual method 'boolean java.lang.String.equals(java....

APP中需要實現LayoutInflater佈局載入器動態載入佈局,然而開啟程式一執行就閃退。。。 FATAL EXCEPTION: main Process:

Android開發中出現Attempt to invoke virtual method...on a null object reference

摘要: 載入Android佈局檔案時出現錯誤: java.lang.NullPointerException: Attempt to invoke virtual method '........' on a null object reference 出錯原因可能是未能在

Android報錯:Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)'

專案中遇到空指標異常 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Str