我试图将导航抽屉与主页活动分开,以便在所有其他活动中共同使用。 但是,这样做的时候,我尝试更换
setContentView(R.layout.home);
在Home.java中,
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams")
View contentView = inflater.inflate(R.layout.home, null, false);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.addView(contentView, 0);
主页活动中的内容相互重叠,并且列表项不再可单击。
如何解决此问题?我要去哪里错了?请帮忙。
完整的源代码位于:
您还可以随意引用同一项目本身中的其他文件。