ouTubePlayerSupportFragment重复的ID

ouTubePlayerSupportFragment重复的ID

本文介绍了在片段YouTubePlayerSupportFragment重复的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的API的Youtube执行播放视频,但我得到的XML重复的ID 0x7f080039一个错误。任何想法如何解决这个问题?

我的片段exends YouTubePlayerSupportFragment:

  @覆盖
    公共查看onCreateView(LayoutInflater充气器,容器的ViewGroup,
                             捆绑savedInstanceState){        的System.out.println();
        //充气的布局该片段
        查看查看= inflater.inflate(R.layout.feed_video,集装箱,FALSE);        YouTubePlayerSupportFragment youTubePlayerFragment =
                (YouTubePlayerSupportFragment)getChildFragmentManager()findFragmentById(R.id.youtube_fragment)。
        youTubePlayerFragment.initialize(DeveloperKey.DEVELOPER_KEY,这一点);        返回视图。
    }

我的XML:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>
    <片段
        类=com.google.android.youtube.player.YouTubePlayerSupportFragment
        机器人:名字=com.google.android.youtube.player.YouTubePlayerSupportFragment
        机器人:ID =@ + ID / youtube_fragment
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    < ListView控件
        机器人:ID =@ + ID / feed_video_list
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:分=#424346
        机器人:dividerHeight =2DP>    < /&的ListView GT;< / LinearLayout中>

我的错误:

 流程:br.com.dotazone,PID:18375
    android.view.InflateException:二进制XML文件行#8:错误充气类片段
            在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            在android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            在android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            在android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            在br.com.dotazone.view.fragment.ChannelYoutubeFragment.onCreateView(ChannelYoutubeFragment.java:79)
            在android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
            在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
            在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
            在android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
            在android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
            在android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
            在android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            在android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
            在android.support.v4.view.ViewPager.populate(ViewPager.java:914)
            在android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
            在android.view.View.measure(View.java:17350)
            在android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
            在android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            在android.view.View.measure(View.java:17350)
            在android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:704)
            在android.view.View.measure(View.java:17350)
            在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            在android.view.View.measure(View.java:17350)
            在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
            在android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
            在android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            在android.view.View.measure(View.java:17350)
            在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2505)
            在android.view.View.measure(View.java:17350)
            在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2175)
            在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1316)
            在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1513)
            在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
            在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6388)
            在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:803)
            在android.view.Choreographer.doCallbacks(Choreographer.java:603)
            在android.view.Choreographer.doFrame(Choreographer.java:573)
            在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:789)
            在android.os.Handler.handleCallback(Handler.java:733)
            在android.os.Handler.dispatchMessage(Handler.java:95)
            在android.os.Looper.loop(Looper.java:157)
            在android.app.ActivityThread.main(ActivityThread.java:5293)
            在java.lang.reflect.Method.invokeNative(本机方法)
            在java.lang.reflect.Method.invoke(Method.java:515)
            在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1265)
            在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            在dalvik.system.NativeStart.main(本机方法)
     java.lang.IllegalArgumentException异常:二进制XML文件行#8:造成重复ID 0x7f080039,标记为空,或父母ID为0x0与com.google.android.youtube.player.YouTubePlayerSupportFragmentyer.YouTubePlayerSupportFragment另一片段


解决方案

在其上的布局被定义嵌套的片段出现此错误,请尝试从XML布局中删除您的片段,并用的FrameLayout取代它成为一个占位符,然后实例化你的片段在动态code。

I am trying use API Youtube to execute play video, but I get a error in XML Duplicated ID 0x7f080039. Any idea how to solve this problem?

My Fragment exends YouTubePlayerSupportFragment :

   @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        System.out.println();
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.feed_video, container, false);

        YouTubePlayerSupportFragment youTubePlayerFragment =
                (YouTubePlayerSupportFragment) getChildFragmentManager().findFragmentById(R.id.youtube_fragment);
        youTubePlayerFragment.initialize(DeveloperKey.DEVELOPER_KEY, this);

        return view;
    }

My XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <fragment
        class="com.google.android.youtube.player.YouTubePlayerSupportFragment"
        android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment"
        android:id="@+id/youtube_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <ListView
        android:id="@+id/feed_video_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:divider="#424346"
        android:dividerHeight="2dp">

    </ListView>

</LinearLayout>

My Error:

Process: br.com.dotazone, PID: 18375
    android.view.InflateException: Binary XML file line #8: Error inflating class fragment
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at br.com.dotazone.view.fragment.ChannelYoutubeFragment.onCreateView(ChannelYoutubeFragment.java:79)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
            at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
            at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
            at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
            at android.view.View.measure(View.java:17350)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            at android.view.View.measure(View.java:17350)
            at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:704)
            at android.view.View.measure(View.java:17350)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at android.view.View.measure(View.java:17350)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            at android.view.View.measure(View.java:17350)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2505)
            at android.view.View.measure(View.java:17350)
            at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2175)
            at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1316)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1513)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6388)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
            at android.view.Choreographer.doCallbacks(Choreographer.java:603)
            at android.view.Choreographer.doFrame(Choreographer.java:573)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5293)
            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:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f080039, tag null, or parent id 0x0 with another fragment for com.google.android.youtube.player.YouTubePlayerSupportFragmentyer.YouTubePlayerSupportFragment
解决方案

this error occurs on Nested Fragments which has been defined in layout , try remove your Fragment from Xml Layout and replace it with a FrameLayout as a PlaceHolder then instantiate your Fragment dynamically in code.

这篇关于在片段YouTubePlayerSupportFragment重复的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 16:40