我正在开发一个android应用程序,所以当我在开发过程中我在片段类中遇到了一些麻烦。如何重定向到活动类的一个片段类(onOptionsItemSelected)
我有两个班, 类A是活动类和B类是片段类
当我在活动就是一个类,我想回我用的是onOptionsItemSelected的片段B类重定向到片段类。
我尝试了几种方法来实现这一点,不幸的是我不能做到这一点。任何人都可以帮助我,这对我来说是非常大的帮助。
这里是我的代码
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent GotoFragmentB= new Intent(A.this, B.class);
startActivity(GotoFragmentB);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
你的意思(R.id.frame_layout_id)这是布局的名字取代的ID? – CHAMI
没有你的FrameLayout的id –