我有一个活动,我在其中创建选项卡,每个选项卡对应一个活动
我创建选项卡的活动:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ActionBar bar = getSupportActionBar();
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Resources res = getResources();
LocalActivityManager mlam = new LocalActivityManager(this, false);
final TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
mlam.dispatchCreate(savedInstanceState);
tabHost.setup(mlam);
TabHost.TabSpec spec;
Intent intent;
// TabHost tabHost = getTabHost();
// tabHost.setup();
TabSpec specAll = tabHost.newTabSpec("All");
specAll.setIndicator("All");
Intent allIntent = new Intent(this, allActivity.class);
specAll.setContent(allIntent);
// specAll.setContent(R.id.allList);
Log.d("SpecAll", "" + specAll.setContent(allIntent));
TabSpec specIn = tabHost.newTabSpec("in");
specIn.setIndicator("In");
Intent inIntent = new Intent(this, inActivity.class);
specIn.setContent(inIntent);
TabSpec specOut = tabHost.newTabSpec("Out");
specOut.setIndicator("Out");
Intent outIntent = new Intent(this, outActivity.class);
specOut.setContent(outIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(specAll); // Adding all tab
tabHost.addTab(specIn); // Adding in tab
tabHost.addTab(specOut); // Adding out tab
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
int i = tabHost.getCurrentTab();
// Log.i("@@@@@@@@ ANN CLICK TAB NUMBER", "------" + i);
if (i == 0) {
Log.d("TAB", "" + i);
} else if (i == 1) {
Log.d("TAB", "" + i);
} else
Log.d("TAB", "" + i);
}
});
}
我需要知道为什么当我调用选项卡的活动时,为什么我不能进入 OnResume() 方法。我只能在 OnCreate 和 onStart 上输入。在 onResume 内的 Log.d 下面的代码中永远不会显示。
一个选项卡的活动:
ProgressDialog pDialog;
EfficientAdapter adap;
Databasehandler db;
ArrayList<Message> menuItems = new ArrayList<Message>();
int current_page = 0;
int index = 0;
int limit = 0;
private static final int TYPE_MO = 0;
private static final int TYPE_MT = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.all);
}
@Override
public void onStart() {
super.onStart();
db = new Databasehandler(this);
List<Message> messages;
messages = db.getMessages(0, 5);
index += 5;
limit = limit + 5;
for (Message mg : messages) {
// Log.d("mpika",mg.getBody());
menuItems.add(new Message(mg.getID(), mg.getPhoneNumber(), mg
.getBody(), mg.getStatus(), mg.getIsMO(), mg.getDate()));
}
adap = new EfficientAdapter(this, menuItems);
ListView lv = (ListView) findViewById(R.id.listall);
// Creating a button - Load More
Button btnLoadMore = new Button(this);
btnLoadMore.setText("Load More");
// Adding button to listview at footer
lv.addFooterView(btnLoadMore);
lv.setAdapter(adap);
btnLoadMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// Starting a new async task
// CharSequence text = "Ok dude you pressed me ";
// Toast toast = Toast.makeText(getApplicationContext(), text,
// Toast.LENGTH_SHORT);
// toast.show();
new loadMoreListView().execute();
}
});
db.close();
}
@Override
public void onResume()
{
super.onResume();
Log.d("OnResume", "inside onResume");
}