相关疑难解决方法(0)

Android RecyclerView:将布局文件LIST更改为GRID onOptionItemSelected

我正在开发一个在线购物的Android应用程序.我为使用产品列表创建了以下视图RecyclerView,因为我想在选择选项菜单项时更改视图:

我创建了以下适配器名称ProductAdapter,因为我已经实现了用于更改布局的代码,onCreateViewHolder用于根据布尔值选择布局文件.

适配器代码ProductAdapter:

    /***
     * ADAPTER for Product to binding rows in List
     */
    private class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductRowHolder> {

        private List<Product> productList;

        private Context mContext;

        public ProductAdapter(Context context, List<Product> feedItemList) {
            this.productList = feedItemList;
            this.mContext = context;
        }

        @Override
        public ProductRowHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            View v = LayoutInflater.from(viewGroup.getContext()).inflate(isProductViewAsList ? R.layout.product_row_layout_list : R.layout.product_row_layout_grid, null);
            ProductRowHolder mh = new ProductRowHolder(v);
            return mh;
        }

        @Override
        public void onBindViewHolder(ProductRowHolder …
Run Code Online (Sandbox Code Playgroud)

android android-edittext android-recyclerview

34
推荐指数
3
解决办法
4万
查看次数

在 RecyclerView 中显示原生广告

我正在使用 RecyclerView。其中我必须在 GridLayout Manager 中显示两个项目,并且跨度计数为 2,才能以全宽显示原生广告。谁能帮我。输出如图 1 所示

我需要的实际输出如图2

android ads android-layout native-ads

3
推荐指数
1
解决办法
6658
查看次数