0

子アクティビティを含む 3 つの TAB があります。問題は、1 つの TAB のいずれかをクリックしても、メインのアクティビティが表示されないことです.3 つの TAB バーのこれらの中にメインのアクティビティを表示するにはどうすればよいですか...誰もがこれに対する解決策を持っています. ?

事前にt​​hnx.. :)

Tabmain TabActivity

    TabHost tabHost = getTabHost();
    TabSpec HomeSpec = tabHost.newTabSpec("Home");
    HomeSpec.setIndicator("Home", getResources().getDrawable(R.drawable.home));
    Intent HomeIntent = new Intent(this, HomeMediator.class);
    HomeSpec.setContent(HomeIntent);

    TabSpec SearchSpec = tabHost.newTabSpec("Search");
    SearchSpec.setIndicator("Search", getResources().getDrawable(R.drawable.search));
    Intent songsIntent = new Intent(this, SearchMediator.class);
    SearchSpec.setContent(songsIntent);

    TabSpec TreeInfoSpac = tabHost.newTabSpec("Tree Info");
    TreeInfoSpac.setIndicator("Botanical Name", getResources().getDrawable(R.drawable.carrot));
    Intent videosIntent = new Intent(this, BotaniacalMediator.class);
    TreeInfoSpac.setContent(videosIntent);

    tabHost.addTab(HomeSpec);
    tabHost.addTab(SearchSpec);
    tabHost.addTab(TreeInfoSpac);
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {
            // TODO Auto-generated method stub

        }
    });

TabGroupActivity;

private ArrayList<String> mIdList;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (mIdList == null) {
        mIdList = new ArrayList<String>();

    }
}


public void finishFromChild(Activity child) {
    LocalActivityManager manager = getLocalActivityManager();
    int index = mIdList.size() - 1;

    if (index < 0) {
        finish();
        return;
    }

    manager.destroyActivity(mIdList.get(index), true);
    Log.i("Activity Finish:", manager.getCurrentId());
    mIdList.remove(index);
    index--;
    String lastId = mIdList.get(index);
    Intent lastIntent = manager.getActivity(lastId).getIntent();
    Window newWindow = manager.startActivity(lastId, lastIntent);
    setContentView(newWindow.getDecorView());
}

public void startChildActivity(String Id, Intent intent) {

    Window window = getLocalActivityManager().startActivity(Id,
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if (window != null) {
        mIdList.add(Id);
        setContentView(window.getDecorView());
        Log.i("Activity Start:", getLocalActivityManager().getCurrentId());
    }
}

ホームメディエーター

public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    group = this;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mediator);
    Intent LoginIntent = new Intent(HomeMediator.this, home.class);
    startChildActivity("Home", LoginIntent);

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    parentActivity = (TabGroupActivity) getParent();
}

public void btnInfo_Click(View v) {
    Intent i = new Intent(getParent(), records.class);
    i.putExtra("VAL", "BotanicalName");
    parentActivity.startChildActivity("Botanical", i);
}
4

2 に答える 2

0

以下のように最初のタブスペックで設定できます

  Intent HomeIntent = new Intent(this, MainClass.class);
  HomeSpec.setContent(HomeIntent);
于 2012-08-23T11:52:00.683 に答える
0

あなたの要点は正確にはわかりませんが、 OnTabListener start Intent を使用するには..

Intent main = new Intent (yourclass.this, MainClass.class);
startActivity(main);
于 2012-08-23T11:01:49.163 に答える