使用fragment关于inflate的问题
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,真是头疼,有没有大婶解决过类似的错啊
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,真是头疼,有没有大婶解决过类似的错啊
...全文
相关推荐
Android 解决嵌套Fragment无法接收onCreateOptionsMenu事件的问题
然而,在使用Fragment时,尤其是当一个Fragment内嵌套了另一个Fragment(即嵌套Fragment)时,开发者可能会遇到一个问题,那就是嵌套的二级Fragment无法正确接收到`onCreateOptionsMenu
解决fragment卡顿问题
及时清理不再使用的资源,减少内存泄漏,都有助于提高Fragment的运行效率。通过上述策略,我们可以有效地解决Fragment卡顿的问题,提升应用的用户体验。
Android Fragment的使用
首先,Fragment的引入主要是为了解决不同尺寸屏幕的设备(如手机、平板)上的UI适配问题。在同一个Activity中,我们可以添加、移除或替换多个Fragment,从而实现灵活的界面布局。
Fragment里添加ListView不要用ListFragment
the layout for this fragment View view = inflater.inflate(R.layout.fragment_custom, container, false
Fragment开发实例
这可能包括如何处理Fragment的点击事件、如何更新Fragment的UI、如何处理Fragment的保存和恢复状态等问题。


