我需要使用程序兼容性V7中引入新的工具栏功能:21阅读SO跟帖这里和android的博客文章在这里。我从博客文章中精确地复制了工具栏片段到我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar <- Line 8
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
问题是我得到:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blabla.PrefActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
Run Code Online (Sandbox Code Playgroud)
有趣的是,如果我删除这一行: android:minHeight="?attr/actionBarSize"
有用。所以问题不是因为项目依赖关系等等。看来我只能访问 ?attr 元素,如 actionBarSize 或 colorPrimary
不用说我已经添加了 AppCompat 依赖项。并且该活动是从 PreferenceActivity 继承的。这是我的毕业证书:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
}
Run Code Online (Sandbox Code Playgroud)
在这里和这里人们随机报告解决问题。但是我的随机在过去两天没有工作。
编辑:
这是我的活动:
public class PrefActivity extends PreferenceActivity {
private Toolbar …Run Code Online (Sandbox Code Playgroud) 我想使用新推出的登录提供商,Twitter推出的Digits.一切正常,直到我想让时间来验证所描述的第三方服务器上的用户凭据(亚马逊Cognito在我的情况)这里.
TwitterAuthConfig authConfig = TwitterCore.getInstance().getAuthConfig();
TwitterAuthToken authToken = session.getAuthToken();
OAuthSigning oauthSigning = new OAuthSigning(authConfig, authToken);
Run Code Online (Sandbox Code Playgroud)
在我的情况下session.getAuthToken();返回一个AuthToken实例而不是TwitterAuthToken,然后我无法将其传递给OAuthSigning()