请教下android 这种新手引导功能该怎么实现?
1、第一阶段:加在首页的PopupWindow上面
private void addFeatureGuide() {
LayoutInflater layoutInflater = LayoutInflater.from(this);
LinearLayout popContentView = (LinearLayout) layoutInflater.inflate(R.layout.popup, null);
PopupWindow popupWindow = new PopupWindow(popContentView, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
popupWindow.showAtLocation(this.findViewById(R.id.main_root), Gravity.CENTER, 0, 0);
}
在onResume的时候调用addFeatureGuide()方法。
这样应该OK了吧?不!Run的时候报错了:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to resume activity {com.example/com.example.MyActivity}: android.view.WindowManager$BadTokenException: Unable to add window — token null is not valid; is your activity running?
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)...
16025