Autore Topic: Passaggio da un Activity ad un'altra  (Letto 543 volte)

Offline andrew1607

  • Nuovo arrivato
  • *
  • Post: 1
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy S3
  • Sistema operativo:
    Windows 8
Passaggio da un Activity ad un'altra
« il: 16 Marzo 2014, 12:24:45 CET »
0
Salve Ragazzi sono nuovo di android volevo chiedervi aiuto su questa applicazione abbastanza semplice tramite un bottone deve solo passare ad un altra activity il codice mi sembra corretto... l'intento è di realizzare un app per la mia università grazie a tutti per l aiuto :D
Gli faccio fare prima lo splash e fin qui tutto bene ma quando clicco sul bottone esce Unfortunately, ... has stopped

Codice (Java): [Seleziona]
public class SplashScreen extends Activity {
         
    // Splash screen timer
    private static int SPLASH_TIME_OUT = 3000;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splashactivity);
 
        new Handler().postDelayed(new Runnable() {
 
            /*
             * Showing splash screen with a timer. This will be useful when you
             * want to show case your app logo / company
             */

 
            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
                Intent i = new Intent(SplashScreen.this, MainActivity.class);
                startActivity(i);
 
                // close this activity
                finish();
            }
        }, SPLASH_TIME_OUT);
    }
 
}

Poi...

Codice (Java): [Seleziona]
public class MainActivity extends Activity  {
       
       
        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);
        Button button1 = (Button)findViewById(R.id.btmeconomia);
       
       
       
        button1.setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                                Intent intent = new Intent(MainActivity.this, ClassEconomia.class);
                                startActivity(intent);
                               
                        }
        });
       
    }    
}  

e l'altra acitvity dove alla pressione dovrebbe passare è questa

Codice (Java): [Seleziona]
public class ClassEconomia extends Activity {
       
        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.seconomia);
       

        }
        }

e infine il mio manifest

Codice (XML): [Seleziona]
 <uses-sdk
       android:minSdkVersion="8"
       android:targetSdkVersion="19" />
 
 
 <supports-screens android:anyDensity="true" />

   <application
       android:allowBackup="true"
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:theme="@style/AppTheme" >
        <!-- Splash screen -->
        <activity
           android:name="com.muromega.muro.launcher.SplashScreen"
           android:label="@string/app_name"
           android:screenOrientation="portrait"
           android:theme="@android:style/Theme.Black.NoTitleBar" >
           
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
               
            </intent-filter>
           
        </activity>
        <!-- Main activity -->
        <activity
           android:name="com.muromega.muro.launcher.MainActivity"
           android:label="@string/app_name"
           android:screenOrientation="portrait"
           android:theme="@android:style/Theme.Black.NoTitleBar">
           
        </activity>
        <activity android:name="com.muromega.muro.launcher.ClassEconomia"
                 android:theme="@android:style/Theme.Black.NoTitleBar"
                 android:screenOrientation="portrait">
           
        </activity>
       
       
    </application>

</manifest>

e questo è il mio LogCat

Codice: [Seleziona]
03-15 16:19:47.252: E/AndroidRuntime(1493): FATAL EXCEPTION: main
03-15 16:19:47.252: E/AndroidRuntime(1493): Process: com.muromega.muro, PID: 1493
03-15 16:19:47.252: E/AndroidRuntime(1493): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.muromega.muro/com.muromega.muro.prg.ClassEconomia}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.os.Handler.dispatchMessage(Handler.java:102)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.os.Looper.loop(Looper.java:136)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread.main(ActivityThread.java:5017)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at java.lang.reflect.Method.invokeNative(Native Method)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at java.lang.reflect.Method.invoke(Method.java:515)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at dalvik.system.NativeStart.main(Native Method)
03-15 16:19:47.252: E/AndroidRuntime(1493): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.createView(LayoutInflater.java:620)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.Activity.setContentView(Activity.java:1929)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at com.muromega.muro.prg.ClassEconomia.onCreate(ClassEconomia.java:13)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.Activity.performCreate(Activity.java:5231)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-15 16:19:47.252: E/AndroidRuntime(1493):         ... 11 more
03-15 16:19:47.252: E/AndroidRuntime(1493): Caused by: java.lang.reflect.InvocationTargetException
03-15 16:19:47.252: E/AndroidRuntime(1493):         at java.lang.reflect.Constructor.constructNative(Native Method)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.LayoutInflater.createView(LayoutInflater.java:594)
03-15 16:19:47.252: E/AndroidRuntime(1493):         ... 23 more
03-15 16:19:47.252: E/AndroidRuntime(1493): Caused by: java.lang.OutOfMemoryError
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.content.res.Resources.loadDrawable(Resources.java:2110)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.View.<init>(View.java:3554)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.View.<init>(View.java:3484)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.view.ViewGroup.<init>(ViewGroup.java:464)
03-15 16:19:47.252: E/AndroidRuntime(1493):         at android.widget.RelativeLayout.<init>(RelativeLayout.java:236)
03-15 16:19:47.252: E/AndroidRuntime(1493):         ... 26 more

Il codice sembra corretto, scusate la mia ignoranza, ma non capisco dove sia l'errore

Offline mirkus87

  • Utente junior
  • **
  • Post: 56
  • Respect: +1
    • Mostra profilo
  • Dispositivo Android:
    Galaxy S2
  • Play Store ID:
    Mirko Vitiello
  • Sistema operativo:
    Windows 7
Re:Passaggio da un Activity ad un'altra
« Risposta #1 il: 16 Marzo 2014, 13:08:40 CET »
0
Quando si verificano errori del genere la prima cosa che faccio è googlare :)

https://www.google.it/search?q=android.view.InflateException%3A+Binary+XML+file+line+%232%3A+Error+inflating+class+%3Cunknown%3E&oq=android.view.InflateException%3A+Binary+XML+file+line+%232%3A+Error+inflating+class+%3Cunknown%3E&aqs=chrome..69i57.576j0j7&sourceid=chrome&espv=2&es_sm=122&ie=UTF-8

Qualche risultato esce (soprattutto su stackoverflow), prova a vedere se per caso qualcun'altro è nelle tue stesse condizioni ed ha risolto, spero di si :)