- Forum-Beiträge: 209
07.06.2011, 22:56:59 via Website
07.06.2011 22:56:59 via Website
2 public TextView textview;
3 public JSONObject Jarr;
4 public ProgressDialog progDialog;
5 public LinearLayout ll;
6
7
8
9 /** Called when the activity is first created. */
10 @Override
11 public void onCreate(Bundle savedInstanceState) {
12 super.onCreate(savedInstanceState);
13 setContentView(R.layout.main);
14 final TableLayout tl = new TableLayout(this);
15 final TableRow tr = new TableRow(this);
16 final TextView labelTV = new TextView(this);
17 final TextView labelTV2 = new TextView(this);
18
19 Resources res = getResources(); // Resource object to get Drawables
20 TabHost tabHost = getTabHost(); // The activity TabHost
21 TabHost.TabSpec spec; // Resusable TabSpec for each tab
22 Intent intent; // Reusable Intent for each tab
23
24 // Create an Intent to launch an Activity for the tab (to be reused)
25 intent = new Intent().setClass(this, ArtistsActivity.class);
26
27 // Initialize a TabSpec for each tab and add it to the TabHost
28 spec = tabHost.newTabSpec("artists").setIndicator("Artists",
29 res.getDrawable(R.drawable.ic_tab_artists))
30 .setContent(new TabHost.TabContentFactory() {
31
32 public View createTabContent(String tag) {
33
34
35
36 ll = (LinearLayout) findViewById(R.id.ll1);
37 tl.setId(100);
38 tl.setStretchAllColumns(true);
39 tl.setBackgroundColor(Color.WHITE);
40 ll.addView(tl);
41
42 tr.setId(200);
43 tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
44
45 tl.addView(tr);
46 // Create a TextView to house the name of the province
47
48 labelTV.setId(200);
49
50 labelTV.setText(getApplicationContext().getString(R.string.tipps));
51 labelTV.setTextColor(Color.BLACK);
52 tr.addView(labelTV);
53 labelTV2.setId(201);
54 labelTV2.setText("2. Zelle");
55 labelTV2.setTextColor(Color.BLACK);
56 tr.addView(labelTV2);
57 textview =(TextView) findViewById(R.id.textView1);
58 textview.setText("This is the Artists tab");
59
60 return ll;
61 }
62 });
63 tabHost.addTab(spec);
64
65 // Do the same for the other tabs
66 intent = new Intent().setClass(this, AlbumsActivity.class);
67 spec = tabHost.newTabSpec("albums").setIndicator("Albums",
68 res.getDrawable(R.drawable.ic_tab_albums))
69 .setContent(intent);
70 tabHost.addTab(spec);
71
72 intent = new Intent().setClass(this, SongsActivity.class);
73 spec = tabHost.newTabSpec("songs").setIndicator("Songs",
74 res.getDrawable(R.drawable.ic_tab_songs))
75 .setContent(intent);
76 tabHost.addTab(spec);
77
78 tabHost.setCurrentTab(1);
79 }
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.