使用fragment关于inflate的问题

敌花师 2015-05-29 01:19:36
xml视图报的log信息如下:
android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F030039.
at android.content.res.BridgeResources.throwException(BridgeResources.java:693)
at android.content.res.BridgeResources.getLayout(BridgeResources.java:271)
at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
at com.fanwe.p2p.customview.SDSimpleTitleView.<init>(SDSimpleTitleView.java:146)

SDSimpleTitleView.java:146行代码是inflater.inflate(R.layout.no2view_simple_title, this, true);具体代码如下
public SDSimpleTitleView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.view_simple_title, this, true);
}
关于R.layout.view_simple_title,这个页面没错,并且我clean了project,还是报这个错,网上有人说是先得setContentView,
可是这是fragment,没有setContentView,真是头疼,有没有大婶解决过类似的错啊
...全文
531 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
敌花师 2015-06-03
  • 打赏
  • 举报
回复
本身和inflate没什么关系,好像是引用jar包的问题,我本身项目就引用library,又引用了生成的jar包,虽然不直接报错,但是这些暗性的错误很难联想啊
栀暖莺飞 2015-06-01
  • 打赏
  • 举报
回复
你写在oncreateview里面 参数里面有inflate 直接拿来用 不需要你去获取
沐兮晨曦SuKi 2015-05-30
  • 打赏
  • 举报
回复
inflater.inflate(R.layout.view_simple_title, null); 这样写看看
敌花师 2015-05-29
  • 打赏
  • 举报
回复
引用 3 楼 qq115787813 的回复:
为什么要写在构造里面?为什么不写在onCrateView里面?
我也试过,也报错,我试试换最新的sdk解析这个adt
栀暖莺飞 2015-05-29
  • 打赏
  • 举报
回复
为什么要写在构造里面?为什么不写在onCrateView里面?
敌花师 2015-05-29
  • 打赏
  • 举报
回复
引用 1 楼 WantD 的回复:
完整代码贴出来
完整的xml的log The following classes could not be instantiated: - com.fanwe.p2p.customview.SDSimpleTitleView (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details. Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F030044. at android.content.res.BridgeResources.throwException(BridgeResources.java:693) at android.content.res.BridgeResources.getLayout(BridgeResources.java:271) at android.view.LayoutInflater.inflate(LayoutInflater.java:395) at com.fanwe.p2p.customview.SDSimpleTitleView.<init>(SDSimpleTitleView.java:146) at com.fanwe.p2p.customview.SDSimpleTitleView.<init>(SDSimpleTitleView.java:138) at sun.reflect.NativeConstructorAccessorImpl.newInstance0( at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
「已注销」 2015-05-29
  • 打赏
  • 举报
回复
完整代码贴出来

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧