我找到了这个。所以,远没有运气。我使用了他的代码,但我无法克服这个错误。我不熟悉充气机。那么有人可以解释这段代码吗?
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
getWindow().setAttributes(params);
wm.addView(mTopView, params);
这部分代码:
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
给我这个错误The method getLayoutInflater() is undefined for the type Context
有人可以解释我做错了什么吗?