且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android的抽屉式导航片段错误

更新时间:2023-01-10 12:16:05

片段是一个关键的词。你需要的是片段式的变量。因此,例如,把这种在同一节为mTitle:

Fragment is a key word. What you need is a variable of type Fragment. So, for example, put this in the same section as mTitle:

Fragment mFragment = null; 

在您的switch语句,放,例如:

In your switch statement, put, for example:

mFragment = new Welcome();

然后,当你设置的交易,你可以把:

Then, when you're setting up the transaction, you can put:

fragmentManager.beginTransaction()
   .replace(R.id.container, mFragment)

这可能不会解决所有的问题,但应该让你过去,这些编译错误。

This may not solve all your problems, but should get you past these compilation errors.