Salve, sono nuovo, spero che riuscirò a trovare una risposta e magari anche una soluzione ad un mio problema. Sto sviluppando un app per android; per ora mi interessa solo creare l'interfaccia e nello specifico fare un'applicazione con 2 tab. Solo che ogni volta che apro l'app crasha. Il codice è questo:
package com.tecnogroup.cosametto;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class CosaIndosso extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cosa_indosso);
TabHost tabhost = (TabHost) findViewById(R.id.tabhost);
tabhost.setup();
TabSpec spec1 = tabhost.newTabSpec("Tab1");
spec1.setContent(R.layout.foto);
Intent foto = new Intent(CosaIndosso.this, foto.class);
spec1.setContent(foto);
spec1.setIndicator("Tab1");
TabSpec spec2 = tabhost.newTabSpec("Tab2");
spec2.setIndicator("Tab2");
tabhost.addTab(spec1);
tabhost.addTab(spec2);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_cosa_indosso, menu);
return true;
}
}
Mentre il logcat è questo:
11-07 14:16:21.102: D/AndroidRuntime(364): Shutting down VM
11-07 14:16:21.112: W/dalvikvm(364): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-07 14:16:21.122: E/AndroidRuntime(364): FATAL EXCEPTION: main
11-07 14:16:21.122: E/AndroidRuntime(364): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tecnogroup.cosametto/com.tecnogroup.cosametto.CosaIndosso}: java.lang.RuntimeException: Could not create tab content because could not find view with id 2130903041
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.os.Handler.dispatchMessage(Handler.java:99)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.os.Looper.loop(Looper.java:123)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-07 14:16:21.122: E/AndroidRuntime(364): at java.lang.reflect.Method.invokeNative(Native Method)
11-07 14:16:21.122: E/AndroidRuntime(364): at java.lang.reflect.Method.invoke(Method.java:507)
11-07 14:16:21.122: E/AndroidRuntime(364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-07 14:16:21.122: E/AndroidRuntime(364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-07 14:16:21.122: E/AndroidRuntime(364): at dalvik.system.NativeStart.main(Native Method)
11-07 14:16:21.122: E/AndroidRuntime(364): Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id 2130903041
11-07 14:16:21.122: E/AndroidRuntime(364): at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:593)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:584)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.widget.TabHost$TabSpec.setContent(TabHost.java:441)
11-07 14:16:21.122: E/AndroidRuntime(364): at com.tecnogroup.cosametto.CosaIndosso.onCreate(CosaIndosso.java:21)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-07 14:16:21.122: E/AndroidRuntime(364): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-07 14:16:21.122: E/AndroidRuntime(364): ... 11 more
Vi prego di aiutarmi, grazie