2017-03-08 125 views
-2

如何在tabhost之間傳遞參數 我有這個ActivityMain代碼。 我想從imbox傳遞口令,發件箱 謝謝使用Tabhost傳遞參數

+0

你能告訴我們你的代碼,或給我們更多關於你想要做什麼的信息? –

+0

創建界面 –

+0

請參閱http://stackoverflow.com/help/how-to-ask – SMR

回答

0

這是我的代碼

@Override 
    public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 

      TabHost tabHost = getTabHost(); 

      // Inbox Tab 
      TabSpec inboxSpec = tabHost.newTabSpec(INBOX_SPEC); 
      // Tab Icon 
      inboxSpec.setIndicator(INBOX_SPEC, getResources().getDrawable(R.drawable.huevo)); 

      Intent inboxIntent = new Intent(this, InboxActivity.class); 

      startActivity(inboxIntent); 
      // Tab Content 
      inboxSpec.setContent(inboxIntent); 

      // Outbox Tab 
      TabSpec outboxSpec = tabHost.newTabSpec(OUTBOX_SPEC); 
      outboxSpec.setIndicator(OUTBOX_SPEC, getResources().getDrawable(R.drawable.huevodos)); 
      Intent outboxIntent = new Intent(this, OutboxActivity.class); 
      outboxSpec.setContent(outboxIntent); 

      // Profile Tab 
      TabSpec profileSpec = tabHost.newTabSpec(PROFILE_SPEC); 
      profileSpec.setIndicator(PROFILE_SPEC, getResources().getDrawable(R.drawable.lock)); 
      Intent profileIntent = new Intent(this, ProfileActivity.class); 
      profileSpec.setContent(profileIntent); 

      // Adding all TabSpec to TabHost 
      tabHost.addTab(inboxSpec); // Adding Inbox tab 
      tabHost.addTab(outboxSpec); // Adding Outbox tab 
      tabHost.addTab(profileSpec); // Adding Profile tab 
    } 

}

import android.app.ListActivity; 
import android.os.Bundle; 

public class InboxActivity extends ListActivity { 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.inbox_list); 

    } 
}