我的Android应用程序中存在设备特定问题。图标图标onclick一个新的片段应该加载,但它导航到仪表板。它在除三星duos设备之外的所有其他设备上都能正常工作。
@Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.add_deal:
Intent addDealIntent = new Intent(mContext, BaseFragmentActivity.class);
addDealIntent.putExtra("Merchant", merchantInfo);
addDealIntent.putExtra("FragmentClassName", AddDealFragment.class.getName());
addDealIntent.putExtra("toolbarTitle", "Add Deal");
mContext.startActivity(addDealIntent);
break;
case R.id.add_product:
Intent addProductIntent = new Intent(mContext, BaseFragmentActivity.class);
addProductIntent.putExtra("Merchant", merchantInfo);
addProductIntent.putExtra("Categories", mMerchantCategories);
addProductIntent.putExtra("SubCategories", mMerchantSubCategories);
addProductIntent.putExtra("SubSubCategories", mMerchantSubSubCategories);
addProductIntent.putExtra("SuperSubCategories", mMerchantSuperSubCategories);
addProductIntent.putExtra("FragmentClassName", AddProductFragment.class.getName());
addProductIntent.putExtra("toolbarTitle", "Add Product");
mContext.startActivity(addProductIntent);
break;
case R.id.dialog_button_cancel:
dismiss();
break;
default:
break;
}
dismiss();
}
答案 0 :(得分:0)
使用startActivity方法,您只能在activitis之间导航,然后您必须更改片段。
您可以使用此代码更改您的片段:
// Create new fragment and transaction
Fragment newFragment = new ExampleFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack if needed
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();