1. Download our Official Android App: Forums for Android!

Apps Multiple Activities

Discussion in 'Android Development' started by mithrandiir42, Sep 23, 2011.

  1. mithrandiir42

    mithrandiir42 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Sep 23, 2011

    Sep 23, 2011
    3
    0
    5
    First a little background. I'm pretty new to Android development and I feel like I'm lacking some pretty basic concepts so this may just be pretty simple question.

    I'm writing an app which contains three tabs.. let's just call them TabA, TabB, and TabC.

    In my main class which extends TabActivity I have a BluetoothAdapter which handles sending and receiving messages. I initialize the BluetoothAdapter onStart. Part of the initialization tries to reference controls on the three tabs. But my problem is that only TabA (my default tab) has been initialized at this point so when it tries to access TabB and TabC, they're still null.. How can I initialize all 3 activities, and access controls on each of the tabs when receiving messages from the BluetoothAdapter? (Basically I want TabA to contain a TextView to log all messages, TabB will contain a few controls like sliders and checkboxes that will change based on the messages recieved, and TabC will just have an array of buttons that send specific data..)

    Thanks in advance!
     

    Advertisement

  2. mithrandiir42

    mithrandiir42 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Sep 23, 2011

    Sep 23, 2011
    3
    0
    5
    Nevermind folks.. I seem to have figured out a suitable method of doing this...

    When I create the tabs, I just switch to each of them before I do anything else which initializes them

    tabHost.setCurrentTabByTag("tabC");
    tabHost.setCurrentTabByTag("tabB");
    tabHost.setCurrentTabByTag("tabA");

    If there's a better way, I'd still love to know
     

Share This Page

Loading...