0

[ OneClickTwoOptions]

我有一个类别列表和产品列表,直接转到类别列表并单击项目中的项目RecyclerView会将我重定向到我可以编辑类别的活动,并在添加新产品时关注我想要的选择该产品的类别并重定向到类别列表我要单击 RecyclerView 的项目将我重定向到产品活动,将类别添加到产品中。我的代码片段: AddProduct-Activity

private void openProdCategory() {
    Intent intent = new Intent(AddProduct.this, ProdCatList.class);
    startActivityForResult(intent, GET_CATEGORY_REQUEST);
}

CategoryLisy-活动

if (getIntent().hasExtra(String.valueOf(AddProduct.GET_CATEGORY_REQUEST))) {
        prodCatAdapter.setOnItemClickListener(new ProdCatAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(Prod_Cat prodCat) {

                Intent data = new Intent(ProdCatList.this, AddProduct.class);
                data.putExtra(EXTRA_PROD_CATID, prodCat.getProdCatId());
                data.putExtra(EXTRA_PROD_CATNAME, prodCat.getCategoryName());
                setResult(RESULT_OK, data);
                finish();
            }
        });
    } else {
        prodCatAdapter.setOnItemClickListener(new ProdCatAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(Prod_Cat prodCat) {
                Intent intent = new Intent(ProdCatList.this, AddCatProd.class);
                intent.putExtra(AddCatProd.EXTRA_CATID, prodCat.getProdCatId());
                intent.putExtra(AddCatProd.EXTRA_CATTITLE, prodCat.getCategoryName());
                intent.putExtra(AddCatProd.EXTRA_CATDESCRIPTION, prodCat.getCategoryDescription());
                intent.putExtra(AddCatProd.EXTRA_CATPRIOR, String.valueOf(prodCat.getCategoryPriority()));
                startActivityForResult(intent, EDIT_CATPROD_REQUEST);
            }
        });
    }
4

0 回答 0