先說下我的問題,這是錯誤日志。
android.content.res.Resources$NotFoundException: Resource ID #0x7f030029
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:279)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2310)
at android.content.res.Resources.getLayout(Resources.java:1293)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.view.View.inflate(View.java:23389)
at com.cloudmind.activity.MainActivity$MyListAdapter.getView(MainActivity.java:451)
at android.widget.AbsListView.obtainView(AbsListView.java:2428)
at android.widget.ListView.makeAndAddView(ListView.java:2083)
at android.widget.ListView.fillDown(ListView.java:793)
at android.widget.ListView.fillFromTop(ListView.java:859)
at android.widget.ListView.layoutChildren(ListView.java:1816)
at android.widget.AbsListView.onLayout(AbsListView.java:2226)
at android.view.View.layout(View.java:19781)
at android.view.ViewGroup.layout(ViewGroup.java:6144)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19781)
at android.view.ViewGroup.layout(ViewGroup.java:6144)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19781)
at android.view.ViewGroup.layout(ViewGroup.java:6144)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2674)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2377)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7266)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:981)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:721)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
我解決問題的路程
發現問題之後就發R檔案裡邊找這個ID #0x7f030029,發現能找到,是個layout 檔案
網上一頓找資料,發現主要還是三個問題
1.R檔案引用錯誤
2.inflate 檔案的時候 R.Layout.****, 寫成了R.id.*****
3.文本渲染的時候 tv.setTest(),傳了 int 類型
通通檢查了一遍,都沒有解決我的問題,還是找不到檔案。
最後恍然大悟,為了适配不同分辨率,寫了兩套布局檔案, layout,layout-large, 找不到的這個檔案隻在 layout-large 裡邊,layout 裡邊沒有,把 檔案複制到 layout 裡邊,儲存,運作,成功 !!!
可能遇到的問題不一樣,但是靜下心來,發現問題,最終都會被解決的, 加油。