0
我想包括兩個文本和圖像視圖的選項卡布局列表視圖。但是它給了以下日誌貓。在我的應用程序中有三個選項卡,我試圖在第二個和第三個選項卡中包含listview。第二個選項卡工作的更早,但當我粘貼相同的代碼爲第三個選項卡,並顯示一些變化後顯示錯誤最後一個返回語句標籤拋出異常。我搜索了類似的問題,但沒有得到答案。我是android開發新手。ImageView在列表視圖拋出異常在Android
堆棧跟蹤日誌
Process: com.example.shubham.tabexample, PID: 32353
android.view.InflateException: Binary XML file line #56: Binary XML file line #56: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #56: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.shubham.tabexample:id/imgview with resource ID #0x7f0e0094
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.shubham.tabexample:id/imgview" (7f0e0094) is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=3 r=0x7f0e0094}
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:691)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:575)
at android.content.res.Resources.loadDrawable(Resources.java:972)
at android.content.res.TypedArray.getDrawable(TypedArray.java:931)
at android.widget.ImageView.<init>(ImageView.java:167)
at android.widget.ImageView.<init>(ImageView.java:155)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:60)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1026)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1083)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at com.example.shubham.JeevanSathi.Activity.Tab2.onCreateView(Tab2.java:28)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2034)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1239)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1087)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1613)
at android.view.View.measure(View.java:20110)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:713)
07-29 13:10:38.399 32353-32353/com.example.shubham.tabexample E/AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:785)
at android.view.View.measure(View.java:20110)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1080)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:714)
at android.view.View.measure(View.java:20110)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2649)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1586)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1855)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1471)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7009)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:907)
at android.view.Choreographer.doCallbacks(Choreographer.java:709)
at android.view.Choreographer.doFrame(Choreographer.java:644)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:893)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1065)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:926)
Tab2.java
package com.example.shubham.JeevanSathi.Activity;
/**
* Created by Shubham on 7/25/2017.
*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.shubham.JeevanSathi.R;
//Our class extending fragment
public class Tab2 extends Fragment {
//Overriden method onCreateView
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Returning the layout file after inflating
//Change R.layout.tab1 in you classes
return inflater.inflate(R.layout.tab2, container, false);
}
}
show java class –
'由於:android.content.res.Resources $ NotFoundException:Resource「com.example.shubham.tabexample:id/imgview」(7f0e0094)一個Drawable(顏色或路徑):TypedValue {t = 0x12/d = 0x0 a = 3 r = 0x7f0e0094}' –