I'm trying to get my second list fragment to open, but with the imperfect code below it thinks that I want to pass data from the DummyContent to show 'Item x' when I actually don't. What needs to change in the if and/or else statements so that the list fragment opens rather than 'Item x' appearing? I know that ARG_ITEM_ID
is the culprit but I don't know what to change it to.
@Override
public void onItemSelected(String id) {
if("1".equals(id)){
if (mTwoPane) {
Bundle arguments = new Bundle();
arguments.putString(ItemDetailFragment.ARG_ITEM_ID, id);
ContinentsListFragment fragment = new ContinentsListFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
.replace(R.id.item_list, fragment)
.commit();
} else {
Intent detailIntent = new Intent(this, ContinentsListActivity.class);
detailIntent.putExtra(ContinentsListFragment.ARG_ITEM_ID, id);
startActivity(detailIntent);
}
}
}
Aucun commentaire:
Enregistrer un commentaire