Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我已经在Listview中实现了Native Express广告。但当广告刷新时,它会刷新列表视图。_Android_Listview_Admob - Fatal编程技术网

Android 我已经在Listview中实现了Native Express广告。但当广告刷新时,它会刷新列表视图。

Android 我已经在Listview中实现了Native Express广告。但当广告刷新时,它会刷新列表视图。,android,listview,admob,Android,Listview,Admob,我已经在Listview中实现了Native Express广告。但当广告刷新时,它会刷新列表视图并将其设置为广告。意味着它会自动将listview滚动到本机广告。即使广告不刷新,也会滚动到广告。那是我不想的。我不知道怎么做。为什么这是自动滚动我的listview 我的本地广告代码如下。 在holder类中。 RelativeLayout adViewContainer; adViewContainer = (RelativeLayout)itemView.findViewById(R.id.a

我已经在Listview中实现了Native Express广告。但当广告刷新时,它会刷新列表视图并将其设置为广告。意味着它会自动将listview滚动到本机广告。即使广告不刷新,也会滚动到广告。那是我不想的。我不知道怎么做。为什么这是自动滚动我的listview

我的本地广告代码如下。 在holder类中。

RelativeLayout adViewContainer;
adViewContainer = (RelativeLayout)itemView.findViewById(R.id.adMobView); 
适配器类中的

holder.adViewContainer.setVisibility(View.VISIBLE);
        holder.adViewContainer.removeAllViews();
        NativeExpressAdView mAdView = new NativeExpressAdView(context);
        mAdView.setAdSize(new AdSize(320, 300));
        mAdView.setAdUnitId(Constant.ADMOB_AD_UNIT_ID);
        holder.adViewContainer.addView(mAdView);
        AdRequest request = new AdRequest.Builder().build();
        mAdView.loadAd(request);

这是一种众所周知的行为。要阻止此操作,请将下面的XML代码行添加到列表视图的根级别视图中(例如:顶级RelativeLayout)

android:descendantFocusability="blocksDescendants"