ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
514
514
EMPFEHLEN
-
Hey folks,
ich bin neu in der Java for Android Ecke und versuche gerade in einem Demoprojekt ein wenig rumzuspielen.
mein Ziel ist es aus einer "Activity" extendeten Klasse eine andere Klasse mit der Erweiterung "TabActivity" aufzurufen. Problem dabei: Es geht nicht
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
public class Test123Activity extends Activity implements android.view.View.OnClickListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View v = findViewById(R.id.Button1); v.setOnClickListener(this); ((Button)v).setText("Click To Get Forwarded"); } public void showToast(CharSequence text){ Context context = getApplicationContext(); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } public void onClick(View view) { switch (view.getId()) { case R.id.Button1: ((Button)view).setText("...Pressed"); showToast("You're now being forwarded to another page..."); Intent i = new Intent(this, TabControlActivity.class); startActivity(i); break; default: ((Button)view).setText("...Pressed"); } } }
meine TabControlKlasse sieht so aus:
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
public class TabControl extends TabActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_tabbar); Resources resources = getResources(); /* contains resources, like drawables in path >>resources */ TabHost tabHost = getTabHost(); /* Container instance for handling tabs */ TabHost.TabSpec tabSpecification; /* Reusable for Tab Specification */ Intent intent; /* Reusable */ /* Intent to launch an Activity for the tab (can be reused) */ intent = new Intent().setClass(this, LedActivity.class); // Initialization and specification for each tab in order to add them to the TabHost tabSpecification = tabHost.newTabSpec("LedActivity").setIndicator("LED Configuration", resources.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(tabSpecification); // Do the same for the other tabs intent = new Intent().setClass(this, someActivity.class); tabSpecification = tabHost.newTabSpec("someActivity").setIndicator("Tab 1", resources.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(tabSpecification); intent = new Intent().setClass(this, someOtherActivity.class); tabSpecification = tabHost.newTabSpec("someOtherActivity").setIndicator("Tab 2", resources.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(tabSpecification); tabHost.setCurrentTab(1); } }
Gehe ich jetzt hin und verweise statt auf meine TabControl Klasse auf eine ganz normal Activity extended Klasse funktioniert es.
Das ist momentan noch etwas über meinem Niveau, daher bräuchte ich einen kleinen Denkanstoß.
Mercii
(Manifest und Layout File kann ich nach Wunsch auch gern posten)Christopher Columbus didn't need directions, neither do we!
Alles hat eine Logik. Selbst wenn es keine Logik gibt.
***
NetBeans 7.x, GlassFish v3
JSF 2.0
Java EE
Ähnliche Themen
-
Gesucht! : Halbwegs vernüftige Doc der Komponentenbibs für Java Android UI
Von Bexx im Forum JavaAntworten: 7Letzter Beitrag: 03.08.11, 15:00 -
Untersch. CSS-Def für CSS-Class
Von TIMS_Ralf im Forum CSSAntworten: 3Letzter Beitrag: 03.02.11, 14:28 -
openGL - Funktionen in untersch. Threads
Von Cromon im Forum C/C++Antworten: 2Letzter Beitrag: 06.09.09, 10:58 -
[Windows Small Bussines Server 2003] Processor Activity Alert
Von yellowspam im Forum Microsoft WindowsAntworten: 2Letzter Beitrag: 12.01.09, 11:17 -
UML: "Database" Actor: ins in Activity Diagramm?
Von sth_Weird im Forum Coders TalkAntworten: 0Letzter Beitrag: 17.11.08, 15:19





Zitieren
Login





