我有一个 TabInterface.java 托管五个选项卡。在其中一个选项卡中,我正在使用子活动。当我单击 AddBook 选项卡(扩展 ActivityGroup)时,搜索书页面会正确加载。当我单击搜索按钮时,会生成书籍列表。当我点击这本书时,必须打开一个新页面,但它的程序运行正常,但屏幕上没有显示任何内容。
TabInterface.java
public class TabInterface extends TabActivity
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tablayout);
Resources res = getResources();
TabHost tabHost = getTabHost();
LocalActivityManager mlam = new LocalActivityManager(this, false);
mlam.dispatchCreate(savedInstanceState);
............................................
intent = new Intent().setClass(this, AddBook.class);
spec = tabHost.newTabSpec("AddBook").setIndicator("Add Book", res.getDrawable(R.drawable.tab_icons)).setContent(intent);
tabHost.addTab(spec);
..............................................`
AddBook.java
...........
Intent i = new Intent(this.getBaseContext(), BookList.class);
replaceContentView("blist", i, getApplicationContext());
........
public void replaceContentView(String id, Intent newIntent, Context c)
{
View view = getLocalActivityManager().startActivity(id, newIntent.addFlags(Intent.FLAG_ACTIVITY_CLE AR_TOP)).getDecorView();
this.setContentView(view);
}
..........
BookList.java
......................
private class BookAdapter extends ArrayAdapter < Books > //my custom adater
...................
public View getView(final int position, View convertView, ViewGroup parent)
...................
//in getView function
v.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent k = new Intent(getBaseContext(), BookNew.class);
AddBook ab = (AddBook) getParent();
ab.replaceContentView("bnew", k, getApplicationContext());
}
}
...................
第三个子活动 BookNew.java 运行正常,但未显示输出。当没有标签显示时它工作正常。我可以知道我错在哪里吗?