Ik ben bezig met een tab interface te maken voor het android platform..
Ik heb al enkele source code toepast in mijn code alleen dit mocht niet het juiste effect hebben zoals deze:
http://groups.google.com/...e3c73b966fa4243b?lnk=raot
http://stackoverflow.com/...-of-an-android-tab-widget
Ik heb geen idee hoe ik de tab kleuren kan wijzigen,wanneer er op de tabs wordt gelikt en wanneer niet.
Graag zou ik mijn dat mijn interface er zo uit gaat zien.

JAVA
XML
Voor de mods:
Aangezien ik een specifieke vraag heb valt er weinig op Google te vinden, vandaar dat dit nog mijn enige hoop is.
Ik heb deze for lus toegepast alleen dit mocht niet het juiste effect hebben.
Iemand een oplossing voor dit probleem
Alvast heel erg bedankt !
Ik heb al enkele source code toepast in mijn code alleen dit mocht niet het juiste effect hebben zoals deze:
http://groups.google.com/...e3c73b966fa4243b?lnk=raot
http://stackoverflow.com/...-of-an-android-tab-widget
Ik heb geen idee hoe ik de tab kleuren kan wijzigen,wanneer er op de tabs wordt gelikt en wanneer niet.
Graag zou ik mijn dat mijn interface er zo uit gaat zien.

JAVA
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
39
40
41
42
43
44
| package nl.tabwidget.; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.widget.TabHost; public class HelloTabWidget extends TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, ArtistsActivity.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("artists").setIndicator("Artists", res.getDrawable(R.drawable.tab_artists)) .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs intent = new Intent().setClass(this, AlbumsActivity.class); spec = tabHost.newTabSpec("albums").setIndicator("Albums", res.getDrawable(R.drawable.tab_albums)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, SongsActivity.class); spec = tabHost.newTabSpec("songs").setIndicator("Songs", res.getDrawable(R.drawable.tab_songs)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(2); } } |
XML
XML:
1
2
3
4
5
6
7
8
| <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- When selected, use grey --> <item android:drawable="@drawable/artists_white" android:state_selected="true" /> <!-- When not selected, use white--> <item android:drawable="@drawable/artists_grey" /> </selector> |
Voor de mods:
Aangezien ik een specifieke vraag heb valt er weinig op Google te vinden, vandaar dat dit nog mijn enige hoop is.
Ik heb deze for lus toegepast alleen dit mocht niet het juiste effect hebben.
Java:
1
2
3
4
5
6
7
| TabWidget tw = getTabWidget(); for (int i = 0; i < tw.getChildCount(); i++) { View v = tw.getChildAt(i); v.setBackgroundDrawable(getResources().getDrawable (R.drawable.tabindicator)); } |
Iemand een oplossing voor dit probleem
Alvast heel erg bedankt !
[ Voor 16% gewijzigd door Verwijderd op 06-10-2010 10:07 ]