[]
我有一个类别列表和产品列表,直接转到类别列表,然后单击RecyclerView
中的“项目”将我重定向到可以编辑类别的活动,并在可能的情况下关注在添加新产品时,我想选择该产品的类别并重定向到类别列表,我想单击RecyclerView的项目将我重定向到该产品的活动,将类别添加到该产品。
我的代码片段:
添加产品活动
private void openProdCategory() {
Intent intent = new Intent(AddProduct.this, ProdCatList.class);
startActivityForResult(intent, GET_CATEGORY_REQUEST);
}
CategoryLisy-Activity
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);
}
});
}