1
我试图让我的第二个列表片段打开,但下面的代码不完整,它认为我想从DummyContent传递数据来显示'Item x',当我实际上不'吨。在if和/或else语句中需要改变什么,以便列表片段打开而不是出现'Item x'?我知道ARG_ITEM_ID
是罪魁祸首,但我不知道该如何改变它。替换片段而不传递数据
@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);
}
}
}
我的确记住了这一点,但想要仔细检查 – MacaronLover