我正在尝试使操作栏具有向上箭头以返回菜单,为什么它不起作用...这是我的代码...如果我在另一个应用程序上具有Web视图,它将起作用这里?.....有人可以帮忙吗,没人帮我,请给我一个理由,它不起作用...我试图重做它,但仍然不起作用!
import android.app.ActionBar;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;
public class About extends TabActivity {
private static TabHost tabHost;
private static Intent intent;
private static TabHost.TabSpec spec;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
tabHost = getTabHost();
intent = new Intent().setClass(this, About1.class);
spec = tabHost.newTabSpec("about").setIndicator("ABOUT US").setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, About2.class);
spec = tabHost.newTabSpec("instructors").setIndicator("INSTRUCTORS").setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, About3.class);
spec = tabHost.newTabSpec("disciplines").setIndicator("DISCIPLINES").setContent(intent);
tabHost.addTab(spec);
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
Intent listintent = new Intent(About.this,Menu.class);
startActivity(listintent);
return true;
}
return super.onOptionsItemSelected(item);
}
}
不错的尝试者,但每个人都错了。。。这很简单。有时我讨厌Java。
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
Intent listintent = new Intent(About.this,
Menu.class);
startActivity(listintent);
return true;
问题是这行怪胎:
Intent listintent = new Intent(About.this, Menu.class);
在我上面的代码中!!!不可能像这样:
Intent listintent = new Intent(About.this,
Menu.class);
那太疯狂了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句