我正在使用一个片段,并试图做一些简单的事情,如发射吐司消息并发生问题。我在课堂上扩展了片段。不能在片段中使用MyActivity.this?
public class UsersView extends Fragment {
View myView;
String globalUserID;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
myView = inflater.inflate(R.layout.users, container, false);
//Global
globalUserID = UserSettings.getUserID();
System.out.println("*** USERSETTINGS " + globalUserID);
if (globalUserID == "empty"){
Toast.makeText(UsersView.this, "Something went wrong :(", Toast.LENGTH_LONG).show();
}
// The End
return myView;
}
}
我的麻烦来在祝酒行,其中它不会让我用UsersView.this,因为“没有合适的方法,找到了使文本:”如果我不能使用片段这样,我需要完全回去到绘图板。有什么建议么?一直卡在这
谢谢!你是男人 –