我在模拟器中运行我的应用时遇到错误:它将其缩小到我正在使用的工具栏布局,但我无法确定原因。我正在使用的风格是什么?
这是运行应用程序时的输出:
android.view.InflateException: Binary XML file line #12: Failed to resolve attribute at index 6: TypedValue{t=0x1c/d=0xff212121 a=2 r=0x7f0c0049}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #12: Failed to resolve attribute at index 6: TypedValue{t=0x1c/d=0xff212121 a=2 r=0x7f0c0049}
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.fontaine.nick.touchevents.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x1c/d=0xff212121 a=2 r=0x7f0c0049}
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6890)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7071)
at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1911)
at android.support.design.widget.AppBarLayout$LayoutParams.<init>(AppBarLayout.java:558)
at android.support.design.widget.AppBarLayout.generateLayoutParams(AppBarLayout.java:283)
at android.support.design.widget.AppBarLayout.generateLayoutParams(AppBarLayout.java:97)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.fontaine.nick.touchevents.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我的hoofdscherm.xml(膨胀的主要布局):
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinaterlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/Theme.AppCompat.NoActionBar"
app:layout_scrollFlags="scroll|enterAlways|snap">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/aandelenlijst"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="6dp"
android:onClick="showInputDialog"
android:src="@drawable/ic_action_add"
app:layout_anchor="@id/toolbar"
app:layout_anchorGravity="end|bottom" />
</android.support.design.widget.CoordinatorLayout>
我的styles.xml:
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.fontaine.nick.touchevents"
minSdkVersion 21 //stond intiaal op 15, mss rollbacken indien problemen
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
//compile 'com.android.support:support-v4:23.1.1'
//compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2' //voor de cardviews te swipen
}
MainActivity:
公共类MainActivity扩展了AppCompatActivity {
//de arraylist van strings waarin we de aandelen gaan opslaan die de gebruiker gekozen heeft
ArrayList<String> Aandelenlijst = new ArrayList<String>();
//de arraylist van Stock-objecten waarin de return van de yahoo finance-"get" zal zitten
ArrayList<Stock> mDataSet = new ArrayList<Stock>();
//de Adapter die de bepaalde elementen van de view zal binden aan de desbetreffende properties van de class
StockAdapter adapterke = new StockAdapter(mDataSet);
//handle creëren voor de swiperefreshlayout
SwipeRefreshLayout mSwipeRefreshLayout;
//handle creëren voor de coordinaterlayout
CoordinatorLayout coordinatorLayout;
RecyclerView recyclerView;
//connectie makne met DB
StockQuotesDB db = new StockQuotesDB(this);
StringBuilder sb = new StringBuilder();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hoofdscherm);
//recyclerview stuff goedzetten
recyclerView = (RecyclerView) findViewById(R.id.aandelenlijst);
recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapterke);
recyclerView.setItemAnimator(new DefaultItemAnimator());
//apptoolbar goedzetten
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);