Autore Topic: problemi con TabHost  (Letto 597 volte)

Offline MarcoMarco

  • Nuovo arrivato
  • *
  • Post: 42
  • Respect: 0
    • Mostra profilo
problemi con TabHost
« il: 12 Marzo 2016, 18:50:37 CET »
0
Salve a tutti

Sperando di aver indovinato la sezione giusta del forum vi espongo il mio problema

è da due giorni ormai che tento di creare un classico menu a scorrimento tramite un TabHost ma senza avere successo oggi ho fatto il mio quinto tentativo (seguendo fonti diverse) e mi da lo stesso errore .
Quando tento di aprire l'applicazione sul cellulare (che non parte mi subito come messaggio che l'app si è bloccata in modo anomalo)

vi posto il codice dove mi da l'errore (che si trova nel MainActivity nella funzione onCreate
per esattezza l'errore che mi da si trova in questa riga ma non riesco a capire bene il perchè

Codice (Java): [Seleziona]
setContentView(R.layout.activity_main);

qui il codice completo
Codice (Java): [Seleziona]
package com.example.marco.tabhost_ennesimotest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TabHost tab = (TabHost) findViewById(R.id.tabHost);
        tab.setup();

        TabHost.TabSpec spec1 = tab.newTabSpec("TAB 1");
        spec1.setIndicator("TAB 1");
        spec1.setContent(R.id.layout1);
        tab.addTab(spec1);

        TabHost.TabSpec spec2 = tab.newTabSpec("TAB 2");
        spec2.setIndicator("TAB 2");
        spec2.setContent(R.id.layout2);
        tab.addTab(spec2);

        Button btntest1 = (Button) findViewById(R.id.btnTest1);
        btntest1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"Test 1", Toast.LENGTH_SHORT).show();
            }
        });

        Button btntest2 = (Button) findViewById(R.id.btnTest2);
        btntest2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "Test 2", Toast.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}



qui ci sono gli errori di logcat
Codice (Java): [Seleziona]
03-12 18:48:59.023  17488-17488/com.example.marco.tabhost_ennesimotest E/VdcInflateDelegate﹕ Exception while inflating <vector>
    org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
            at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
            at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
            at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
            at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
            at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
            at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
            at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
            at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:379)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
            at com.example.marco.tabhost_ennesimotest.MainActivity.onCreate(MainActivity.java:17)
            at android.app.Activity.performCreate(Activity.java:5368)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
            at android.app.ActivityThread.access$800(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5486)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
03-12 18:48:59.035  17488-17488/com.example.marco.tabhost_ennesimotest E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.marco.tabhost_ennesimotest, PID: 17488
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.marco.tabhost_ennesimotest/com.example.marco.tabhost_ennesimotest.MainActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2433)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
            at android.app.ActivityThread.access$800(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5486)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
            at android.view.LayoutInflater.createView(LayoutInflater.java:620)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:379)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
            at com.example.marco.tabhost_ennesimotest.MainActivity.onCreate(MainActivity.java:17)
            at android.app.Activity.performCreate(Activity.java:5368)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
            at android.app.ActivityThread.access$800(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5486)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:379)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
            at com.example.marco.tabhost_ennesimotest.MainActivity.onCreate(MainActivity.java:17)
            at android.app.Activity.performCreate(Activity.java:5368)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
            at android.app.ActivityThread.access$800(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5486)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
            at android.content.res.Resources.loadDrawable(Resources.java:2164)
            at android.content.res.Resources.getDrawable(Resources.java:717)
            at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
            at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
            at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
            at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
            at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
            at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
            at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:379)
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
            at com.example.marco.tabhost_ennesimotest.MainActivity.onCreate(MainActivity.java:17)
            at android.app.Activity.performCreate(Activity.java:5368)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2484)
            at android.app.ActivityThread.access$800(ActivityThread.java:158)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5486)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
            at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:958)
            at android.graphics.drawable.Drawable.createFromXml(Drawable.java:893)
            at android.content.res.Resources.loadDrawa



evidentemente mi sfugge qualcosa ma non riesco a capire cosa
Spero che qualcuno mi aiuti a capire dove sbaglio


Grazie in anticipo per le risposte  :D
« Ultima modifica: 12 Marzo 2016, 18:53:23 CET da MarcoMarco »

Offline zezzo

  • Nuovo arrivato
  • *
  • Post: 33
  • Respect: +3
    • Mostra profilo
Re:problemi con TabHost
« Risposta #1 il: 12 Marzo 2016, 19:07:43 CET »
0
Forse potrebbe essere una risorsa che non trova, non sono espertissimo ma intanto puoi iniziare da li e poi ricompilare...

Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016

Offline MarcoMarco

  • Nuovo arrivato
  • *
  • Post: 42
  • Respect: 0
    • Mostra profilo
Re:problemi con TabHost
« Risposta #2 il: 15 Marzo 2016, 23:12:28 CET »
0
Si pure io ci ho pensato ma non riesco a capire cosa di preciso lo scaturisce  :-(