1

我在启动 Fragment 时遇到此错误。有时片段显示,有时不显示,应该只显示一个空白屏幕。当时 logcat 显示“endAllActiveAnimators on 0xa2ee7500 (RippleDrawable) with handle 0xa1c126d0”

也请描述 endAllActiveAnimators

代码如下

   public class SingleArtViewDetail extends BaseActivity {

@BindView(R.id.tabSingleartLayoutHome)
TabLayout tabLayout;
@BindView(R.id.viewPagerSingleartHome)
ViewPager viewPager;
ViewPagerAdapter viewPagerAdapter;
private ViewArtDetailFragment viewArtDetailFragment = new ViewArtDetailFragment();
private CommentsFragment commentsFragment = new CommentsFragment();
private SimilarArtFragment similarArtFragment = new SimilarArtFragment();
Activity activity;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_art_view_detail);
    if(getIntent()!=null) {
        EventBus.getDefault().postSticky(new ArtIdEvent(getIntent().getStringExtra("artid")));

    }
    ButterKnife.bind(this);
    setToolBar("");
    setTabs();
    activity=SingleArtViewDetail.this;
   // EventBus.getDefault().register(this);
}

@Override
protected void onDestroy() {
 //   EventBus.getDefault().unregister(this);
    super.onDestroy();
}

private void setTabs() {
    viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
    viewPagerAdapter.addFrag(viewArtDetailFragment, "");
    viewPagerAdapter.addFrag(commentsFragment, "");
    viewPagerAdapter.addFrag(similarArtFragment, "");
    viewPager.setAdapter(viewPagerAdapter);
    viewPager.setOffscreenPageLimit(3);
    tabLayout.setupWithViewPager(viewPager);
    final int[] ICONS = new int[]{
            R.drawable.ic_addtocart,
            R.drawable.ic_comments,
            R.drawable.ic_similaritems};
    final int[] ICONSUNSELECTED = new int[]{
            R.drawable.ic_addtocartselected,
            R.drawable.ic_commentsselected,
            R.drawable.ic_similaritemsselected};
    tabLayout.getTabAt(0).setIcon(ICONS[0]);
    tabLayout.getTabAt(1).setIcon(ICONSUNSELECTED[1]);
    tabLayout.getTabAt(2).setIcon(ICONSUNSELECTED[2]);
    tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            System.out.println("selected"+tab.getPosition());
            switch (tab.getPosition())
            {
                case 0:
                    tabLayout.getTabAt(0).setIcon(ICONS[0]);
                    break;
                case 1:
                    tabLayout.getTabAt(1).setIcon(ICONS[1]);

                    break;
                case 2:
                    tabLayout.getTabAt(2).setIcon(ICONS[2]);
                    break;
            }
          //  tab.setIcon(R.drawable.newicon);
            //also you can use tab.setCustomView() too
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
            //tab.setIcon(R.drawable.oldicon);
            System.out.println("unselected"+tab.getPosition());
            switch (tab.getPosition())
            {
                case 0:
                    tabLayout.getTabAt(0).setIcon(ICONSUNSELECTED[0]);
                    break;
                case 1:
                    tabLayout.getTabAt(1).setIcon(ICONSUNSELECTED[1]);

                    break;
                case 2:
                    tabLayout.getTabAt(2).setIcon(ICONSUNSELECTED[2]);
                    break;
            }
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            System.out.println(tab);
        }
    });
}}

片段是

 public class ViewArtDetailFragment extends BaseFragment {

Context context;
String artid;
SingleImageModel singleImageModel = new SingleImageModel();
SingleArtDetail singleArtDetail;
@BindView(R.id.layout_artdetail)
LinearLayout layout_artdetail;
@BindView(R.id.progressbar)
ProgressBar progressbar;
@BindView(R.id.pager)
ImageView viewPager;
@BindView(R.id.horizontalscrlview)
HorizontalScrollView horizontalscrlview;
@BindView(R.id.tv_arttitle)
TextView tv_arttitle;
@BindView(R.id.artbaseprice)
TextView tv_artbaseprice;
@BindView(R.id.tv_artownername)
TextView tv_artownername;
@BindView(R.id.tv_artdescrptn)
TextView tv_artdescrptn;
@BindView(R.id.tv_viewdimension)
TextView tv_viewdimension;
@BindView(R.id.tv_viewyearofcreation)
TextView tv_viewyearofcreation;
@BindView(R.id.tv_viewcategory)
TextView tv_viewcategory;
@BindView(R.id.tv_viewsubject)
TextView tv_viewsubject;
@BindView(R.id.tv_viewstyle)
TextView tv_viewstyle;
@BindView(R.id.tv_viewmaterials)
TextView tv_viewmaterials;
@BindView(R.id.tv_viewmedium)
TextView tv_viewmedium;
@BindView(R.id.tv_vieworiginal)
TextView tv_vieworiginal;
@BindView(R.id.tv_viewprint)
TextView tv_viewprint;
@BindView(R.id.thumbnails)
LinearLayout _thumbnails;

@BindView(R.id.tv_copyright)
TextView tv_copyright;
//   private GalleryPagerAdapter _adapter;
private ArrayList<String> thumb_images = new ArrayList<>();
private ArrayList<String> gallery_images = new ArrayList<>();

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

    View view = inflater.inflate(R.layout.fragment_view_art_details, container, false);
    ButterKnife.bind(this, view);
    context = getActivity();
    ArtIdEvent artIdEvent = EventBus.getDefault().getStickyEvent(ArtIdEvent.class);
    artid = artIdEvent.getArtId();
    callingArtDetailApi();
    return view;
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);}}

下面给出了片段 xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
>
<ProgressBar

    android:id="@+id/progressbar"
    android:layout_centerInParent="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<LinearLayout
    android:visibility="gone"

    android:id="@+id/layout_artdetail"
    android:layout_below="@+id/toolbar"
    android:layout_width="wrap_content"
    android:layout_height="match_parent">
    <ScrollView

        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout

            android:layout_marginBottom="80dp"
            android:orientation="vertical"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
            <ImageView
                android:layout_marginRight="@dimen/tabsmall_margin"
                android:layout_marginLeft="@dimen/tabsmall_margin"
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="@dimen/viewpagerheight"
                >
            </ImageView>



            <HorizontalScrollView
                android:id="@+id/horizontalscrlview"
                android:layout_marginRight="@dimen/tabsmall_margin"
                android:layout_marginLeft="@dimen/tabsmall_margin"
                android:layout_width="match_parent"
                android:layout_height="@dimen/horizonalscrollheight"
                android:layout_gravity="bottom"
                >
                <LinearLayout
                    android:id="@+id/thumbnails"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:paddingTop="2dp">

                </LinearLayout>
            </HorizontalScrollView>
            <include
                layout="@layout/content_view_art_detail"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

请帮助解决这个问题,在此先感谢。

编辑

错误的完整日志(由 OP 在评论中发布):

06-29 13:06:55.702 24382-24382/com.cushbuart.cushbuart E/log: onsavedInstanceState 06-29 13:07:01.840 24382-24525/com.cushbuart.cushbuart D/OpenGLRenderer: endAllActiveAnimators on 0x9ecd8b80 (RippleDrawable)句柄 0xa19a4540 06-29 13:07:03.612 24382-24382/com.cushbuart.cushbuart D/EventBus: 没有订阅者注册事件类 com.cushbuart.cushbuart.eventmodel.ArtIdEvent 06-29 13:07:03.612 24382-24382/ com.cushbuart.cushbuart D/EventBus:没有订阅者注册事件类 org.greenrobot.eventbus.NoSubscriberEvent

4

1 回答 1

0

解决了我的问题,这是因为我的 tablayout xml 文件。我把它改成了

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >


    <include
        layout="@layout/toolbar"/>

    <android.support.v4.view.ViewPager
        android:layout_below="@+id/toolbar"
        android:id="@+id/viewPagerSingleartHome"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />


    <android.support.design.widget.TabLayout
        android:id="@+id/tabSingleartLayoutHome"
        app:tabMode="fixed"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:elevation="6dp"
        app:tabTextColor="#d3d3d3"
        app:tabSelectedTextColor="@color/colorwhite"
        app:tabIndicatorColor="@color/colorwhite"
        android:minHeight="?attr/actionBarSize"
        android:layout_alignParentBottom="true"
        />
</RelativeLayout>
于 2017-06-30T06:47:10.220 回答