Kennyc1012 / MultiStateView

Android View that displays different content based on its state
1.22k stars 177 forks source link

setOnClickListener and google ads conflicts #9

Closed qq137712630 closed 8 years ago

qq137712630 commented 8 years ago

setOnClickListener and google ads conflicts, When there is the layout of AdView, setOnClickListener not monitor

setOnClickListener和google ads 冲突, 当有在布局有AdView时,setOnClickListener无法监听

Java

msvXrv.getView(MultiStateView.VIEW_STATE_ERROR).findViewById(R.id.retry)
        .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               ...
            }
        });

XML:

<?xml version="1.0" encoding="utf-8"?>
<com.kennyc.view.MultiStateView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/msv_xrv"
    style="@style/layout_match"
    app:msv_emptyView="@layout/empty_view"
    app:msv_errorView="@layout/error_view"
    app:msv_loadingView="@layout/loading_view"
    app:msv_viewState="content">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        style="@style/layout_wrap"
        android:layout_alignBottom="@+id/xrv_main"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView>

    <com.jcodecraeer.xrecyclerview.XRecyclerView
        android:id="@+id/xrv_main"
        style="@style/layout_match"
        android:layout_marginTop="50dp"
        android:scrollbars="none" />

</com.kennyc.view.MultiStateView>
Kennyc1012 commented 8 years ago

Your layout is not valid, there can only be one view for the Content view in a MultiStateView. The AdView and RecyclerView should be wrapped in another view. By the looks of your layout parameters, it looks like it should be a RelativeLayout

qq137712630 commented 8 years ago

Thanks!

Kennyc1012 commented 8 years ago

Is the issue still occurring?