Java 您需要使用Theme.AppCompat主题
是的,我知道,这个问题被一次又一次地贴在这里。但我找不到任何解决我具体问题的办法 每次我尝试制作一个Snackbar,我的应用程序都会崩溃 您需要将Theme.AppCompat主题(或子代)与 设计库Java 您需要使用Theme.AppCompat主题,java,android,xml,Java,Android,Xml,是的,我知道,这个问题被一次又一次地贴在这里。但我找不到任何解决我具体问题的办法 每次我尝试制作一个Snackbar,我的应用程序都会崩溃 您需要将Theme.AppCompat主题(或子代)与 设计库 嗯。我知道:没有代码就无法调试,因此: 调用和引发错误的行: 类别定义: 舱单的开头 哦,是的:AppTheme和AppTheme.NoActionbar都是Theme.AppCompat的父母 如果您还需要代码,请告诉我。为什么需要使用getApplicationContext(
嗯。我知道:没有代码就无法调试,因此: 调用和引发错误的行:
类别定义:
舱单的开头
哦,是的:AppTheme和AppTheme.NoActionbar都是Theme.AppCompat的父母
如果您还需要代码,请告诉我。为什么需要使用
getApplicationContext()
进行协调或布局
您甚至可以使用新的CoordinatorLayout(MainActivity.this)
。(这使用活动
上下文
而不是应用程序
上下文
)
但你真的应该保持简单。试试这个:
Snackbar.make(findViewById(android.R.id.content), "Logged out.", Snackbar.LENGTH_SHORT).show();
请添加
res/values/styles.xml
和res/values-v21/styles.xml
(如果您有)
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
Snackbar.make(findViewById(android.R.id.content), "Logged out.", Snackbar.LENGTH_SHORT).show();