I just startet to write my first application for Android and now I come to a problem which I cannot solve by myself.
I have to Classes, the first one:
Using java Syntax Highlighting
- import android.app.TabActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.Window;
- import android.view.WindowManager;
- import android.widget.TabHost;
- import ch.xot.sbb.menu;
- public class SBB extends TabActivity {
- private TabHost th_menu;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Window Preference
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
- // End: Window Preference
- // Tabs and Content
- th_menu = getTabHost();
- Intent i_menu = new Intent();
- i_menu.setClass(SBB.this, menu.class);
- Intent i_disp = new Intent();
- i_disp.setClass(SBB.this, display.class);
- // End: Tabs and Content
- // Add Tabs
- th_menu.addTab(th_menu.newTabSpec("menu").setIndicator(this.getString(R.string.schedule)).setContent(i_menu));
- th_menu.addTab(th_menu.newTabSpec("disp").setIndicator(this.getString(R.string.list)).setContent(i_disp));
- // End: Add tabs
- // Set Height
- for (int i = 0; i <= th_menu.getChildCount(); i++) {
- th_menu.getTabWidget().getChildAt(i).getLayoutParams().height = 50;
- }
- // End: Set Height
- }
- public void setTab(int int_tab) {
- th_menu.setCurrentTab(int_tab);
- }
- }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
This is adding some Tab's from an Intent. Now I want to change the Tab from within the second class:
Using java Syntax Highlighting
- import android.app.Activity;
- import android.graphics.Color;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageView;
- import android.widget.TableLayout;
- import android.widget.TextView;
- public class menu extends Activity {
- public SBB cl_owner = null;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Table Layout
- TableLayout tl_layout = new TableLayout(this);
- tl_layout.setBackgroundColor(Color.WHITE);
- // Logo
- ImageView iv_logo = new ImageView(this);
- iv_logo.setImageResource(R.drawable.sbb);
- iv_logo.setAdjustViewBounds(true);
- // End: Logo
- // From Layout
- TextView tv_from = new TextView(this);
- tv_from.setText(R.string.from);
- tv_from.setTextColor(Color.BLACK);
- EditText et_from = new EditText(this);
- // End: From Layout
- // To Layout
- TextView tv_to = new TextView(this);
- tv_to.setText(R.string.to);
- tv_to.setTextColor(Color.BLACK);
- EditText et_to = new EditText(this);
- // End: To Layout
- // Buttons
- Button bt_go = new Button(this);
- bt_go.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v_view) {
- cl_owner.setTab(1);
- }
- });
- // End: Buttons
- // Add to Layout
- tl_layout.addView(iv_logo);
- tl_layout.addView(tv_from);
- tl_layout.addView(et_from);
- tl_layout.addView(tv_to);
- tl_layout.addView(et_to);
- tl_layout.addView(bt_go);
- // End: Add to Layout
- // End: Table Layout
- setContentView(tl_layout);
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
But I don't know how to give to the second Class some Reference to the first one.
Anyone some idea?

