我正在使用https://github.com/amlcurran/ShowcaseView来显示 Menuitems 的 ShowcaseView,如下所示:
MainActivity.java:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set our view from the "main" layout resource
setContentView(R.layout.activity_main);
//getWindow().setBackgroundDrawable(null);
toolbar = (Toolbar) findViewById(R.id.toolbar);
//Toolbar will now take on default actionbar characteristics
setContentView(R.layout.activity_main);
setTitle("DDIT Results");
try {
new ShowcaseView.Builder(MainActivity.this)
.withMaterialShowcase()
.setStyle(R.style.MyTheme)
.setTarget(new ActionItemTarget(MainActivity.this, R.id.action_notify))
.setContentTitle("Enable Notification")
.setContentText("Click On the Button and get notified whenever the Result-table Changes")
.build()
.show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,""+e,Toast.LENGTH_LONG).show();
}
}
这导致应用程序崩溃。
menu_main.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_rateus" android:title="@string/rate_us" android:orderInCategory="100" app:showAsAction="never"/>
<item android:id="@+id/action_notify" android:title="@string/notify" android:icon="@drawable/ic_notifications_none_white_24dp"
android:orderInCategory="100" app:showAsAction="ifRoom" />
<item android:id="@+id/action_privacy_policy" android:title="Privacy Policy" android:orderInCategory="100" app:showAsAction="never"/>
<item android:id="@+id/action_email_us" android:title="@string/action_email_us" android:orderInCategory="100" app:showAsAction="never"/>
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
日志:
java.lang.RuntimeException: insertShowcaseViewWithType cannot be used when the theme has no ActionBar
at com.github.amlcurran.showcaseview.targets.ActionBarReflector.getHomeButton(ActionBarReflector.java:43)
at com.github.amlcurran.showcaseview.targets.ActionBarReflector.getActionBarView(ActionBarReflector.java:36)
at com.github.amlcurran.showcaseview.targets.ActionItemTarget.setUp(ActionItemTarget.java:49)
at com.github.amlcurran.showcaseview.targets.ActionItemTarget.getPoint(ActionItemTarget.java:43)
at com.github.amlcurran.showcaseview.ShowcaseView$1.run(ShowcaseView.java:176)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
是否可以让展示视图针对操作栏中的特定项目?我搜索了这个问题,但没有提出任何解决方案。希望有人能识别这个错误并有一个快速的答案 - 否则我可以在需要时提供更多信息。任何帮助都会得到帮助。