1. Nimm jetzt an unserem Geotel Note - Gewinnspiel teil - Informationen zum Note findest Du hier!
  1. Butch78, 13.12.2011 #1
    Butch78

    Butch78 Threadstarter Junior Mitglied

    Hi Leute,

    seit gestern versuche ich eine Tabbar zu erstellen. Hierzu habe ich auch shcon sehr viel bei Google gesucht und schon einiges gefunden. Nun wollte ich mir eine eigene Tabbar erstellen.

    Der Code dafür sieht zurzeit so aus:

    Code:
     
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055]
    [LEFT][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] test [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Activity {[/SIZE]
    
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TabHost [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Context [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mContext[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE][/LEFT]
    [/LEFT]
    
     
    
    [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] setupTabHost() {[/SIZE]
    [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (TabHost) findViewById(android.R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]tabhost[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setup();[/SIZE]
    [SIZE=2]}[/SIZE][/LEFT]
    [/LEFT]
    
     
    
    [LEFT][SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]/** Called when the activity is first created. */[/COLOR][/SIZE][/COLOR][/SIZE]
    [LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onCreate(Bundle savedInstanceState) {[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onCreate(savedInstanceState);[/SIZE]
    [SIZE=2]setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]editor_tab_bar[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mContext[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]; [/SIZE]
    [SIZE=2]setupTabHost();[/SIZE]
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getTabWidget().setDividerDrawable(R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]tab_divider[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2]setupTab([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TextView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]), getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]tx_editor_info[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]info[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// firstTabSpec.setContent(new Intent(context, EditorTab1.class));[/COLOR][/SIZE][/COLOR][/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] setupTab([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] View view, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String tag, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] dw) {[/SIZE]
    [SIZE=2]View tabview = [I]createTabView[/I]([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getContext(), tag, dw);[/SIZE]
    [SIZE=2]TabSpec spec = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].newTabSpec(tag)[/SIZE]
    [SIZE=2].setIndicator(tabview)[/SIZE]
    [SIZE=2].setContent([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mContext[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], EditorTab1.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]));[/SIZE]
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mTabHost[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].addTab(spec);[/SIZE]
    [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// mTabHost.setOnTabChangedListener(new TabChangeListener());[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
    [/LEFT]
    [SIZE=2][COLOR=#3f7f5f]
    [/COLOR][/SIZE]
    
    [LEFT][SIZE=2]}[/SIZE]
    [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] View createTabView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Context context, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String text, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] dw) {[/SIZE]
    [SIZE=2]View view = LayoutInflater.[I]from[/I](context).inflate(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]editor_layout_tabs_bg[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
    [SIZE=2]TextView tv = (TextView) view.findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]tabsText[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2]tv.setText(text);[/SIZE]
    [SIZE=2]ImageView iv = (ImageView)view.findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]tabsImage[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2]iv.setImageResource(dw); [/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] view;[/SIZE]
    [SIZE=2]}[/SIZE][/LEFT]
    
    
    [SIZE=2]}[/SIZE][/LEFT]
    
    An der Stelle, wo ich meinen Tabs den Content zuweise, scheint es Probleme zu geben.

    .setContent(new Intent(mContext, EditorTab1.class));
    mTabHost.addTab(spec);



    Dann fliegt mir ne Exception um die Ohren:

    Code:
    
    [LEFT]12-13 08:45:05.619: ERROR/AndroidRuntime(29417): /system/csc/feature.xml ==> cannot open file
    [LEFT]12-13 08:45:08.549: ERROR/UinboxLogger(29434): [UinboxReceiver] onReceive() >> Context is android.app.ReceiverRestrictedContext@405236a8
    12-13 08:45:09.329: ERROR/AndroidRuntime(29448): /system/csc/feature.xml ==> cannot open file
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457): FATAL EXCEPTION: main
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.androiddev.test/de.androiddev.test.tabbar.test}: java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.os.Looper.loop(Looper.java:123)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread.main(ActivityThread.java:3687)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at java.lang.reflect.Method.invoke(Method.java:507)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at dalvik.system.NativeStart.main(Native Method)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457): Caused by: java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:674)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.widget.TabHost.setCurrentTab(TabHost.java:348)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.widget.TabHost.addTab(TabHost.java:227)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at de.androiddev.saarlandkochbuch.tabbar.test.setupTab(test.java:42)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at de.androiddev.saarlandkochbuch.tabbar.test.onCreate(test.java:34)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
    12-13 08:45:21.019: ERROR/AndroidRuntime(29457):     ... 11 more
    12-13 08:45:21.049: ERROR/(162): Dumpstate > /data/log/dumpstate_app_error
    12-13 08:47:20.569: ERROR/PowerManagerService(162): CurLock p:3 mPS:1[/LEFT]
    [/LEFT]
    
    


    Könnt ihr mir da evtl. weiterhelfen? ​



    Vielen Danke und Grüße​



    Butch​
     
Die Seite wird geladen...
Ähnliche Themen - Kleines Problem mit Forum Datum
[OFFEN] WebView Probleme Android App Entwicklung Freitag um 23:26 Uhr
[ERLEDIGT] Problem mit Async Task und auszuführender Aufgabe Android App Entwicklung 02.05.2017
[ERLEDIGT] Probleme mit Wear Modul Android App Entwicklung 01.05.2017
[OFFEN] Probleme mit SearchView in ArrayAdapter Android App Entwicklung 28.04.2017
[ERLEDIGT] Problem beim Starten einer neuen Activity Android App Entwicklung 21.03.2017
Verständnisprobleme beim Layout Android App Entwicklung 21.02.2017
Probleme beim Encoding einer Textdatei von Windows Android App Entwicklung 25.01.2017
Probleme mit NFC File Transfer Android App Entwicklung 21.01.2017
Layout-Probleme auf verschiedenen Geräten Android App Entwicklung 19.01.2017
AsyncTasks: "FTP Download" / "FTP liste Daten in Verzeichnis" Probleme Android App Entwicklung 16.01.2017