大家好我在gitLibaray的帮助下在我的Android应用程序中创建了一个关于我们的页面。
代码工作正常,但问题是,当我试图显示版权标识时,它给了我错误,我已经添加了下面的堆栈轨道。 请检查我的代码并纠正我..
About.java
public class About extends Fragment {
public About() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_about, container, false);
String desc = "CINEMATOGRAPHER AND PHOTOGRAPHER";
Element versionElement = new Element();
versionElement.setTitle("Version 1.0");
View aboutPage = new AboutPage(getActivity())
.isRTL(false)
.setDescription(desc)
.setImage(R.mipmap.jdlogo_circle)
.addItem(versionElement)
.addGroup("Connect with us")
.addEmail("JDstudio.in@gmail.com")
.addFacebook("facebook.com/JDstudio.in")
.addYoutube("UC1DbBH3re7wceuz0XdCOJ8Q")
.addInstagram("_jdstudio")
.addItem(getCopyRightsElement())
.create();
return aboutPage;
}
Element getCopyRightsElement() {
Element copyRightsElement = new Element();
final String copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR));
copyRightsElement.setTitle(copyrights);
copyRightsElement.setIconDrawable(R.mipmap.ic_copyright_black_24dp);
copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color);
copyRightsElement.setIconNightTint(android.R.color.white);
copyRightsElement.setGravity(Gravity.CENTER);
return copyRightsElement;
}
}
fragment_about.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.lenovo.jdstudio.About">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
堆栈跟踪
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lenovo.jdstudio, PID: 7627
android.content.res.Resources$NotFoundException: File res/mipmap-xhdpi-v4/ic_copyright_black_24dp.png from xml type xml resource ID #0x7f0d0007
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2430)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2385)
at android.content.res.Resources.getXml(Resources.java:998)
at android.support.graphics.drawable.VectorDrawableCompat.create(VectorDrawableCompat.java:562)
at mehdi.sakout.aboutpage.AboutPage.createItem(AboutPage.java:563)
at mehdi.sakout.aboutpage.AboutPage.addItem(AboutPage.java:407)
at com.example.lenovo.jdstudio.About.onCreateView(About.java:51)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2596)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2383)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2245)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:703)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:501)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2412)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2385)
at android.content.res.Resources.getXml(Resources.java:998)
at android.support.graphics.drawable.VectorDrawableCompat.create(VectorDrawableCompat.java:562)
at mehdi.sakout.aboutpage.AboutPage.createItem(AboutPage.java:563)
at mehdi.sakout.aboutpage.AboutPage.addItem(AboutPage.java:407)
at com.example.lenovo.jdstudio.About.onCreateView(About.java:51)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2596)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2383)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2245)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:703)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:1)
使用unicode
string.xml
中的版权符号,如下所示: -
<string name= "copy_right">© your_String </string>
然后在你的代码中提到: -
Element getCopyRightsElement() {
Element copyRightsElement = new Element();
final String copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR));
copyRightsElement.setTitle(copyrights);
copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color);
copyRightsElement.setGravity(Gravity.CENTER);
return copyRightsElement;
}
答案 1 :(得分:0)
android.content.res.Resources$NotFoundException: File res/mipmap-xhdpi-v4/ic_copyright_black_24dp.png from xml type xml resource ID #0x7f0d0007
以上错误消息明确指出在您的res / mipmap文件夹中找不到 ic_copyright_black_24dp.png 图片检查文件夹是否存在