gpt4 book ai didi

android - Android中有没有像MFC中的onShow一样的布局功能

转载 作者:行者123 更新时间:2023-11-29 02:15:33 24 4
gpt4 key购买 nike

我有一个带有 2 个选项卡的选项卡式布局,每个选项卡都有自己的 View 。我搜索了一个可以覆盖的函数,如果我点击一个选项卡来显示布局,每次都会调用它。

提前致谢...

哈桑·卡利斯坎

编辑:

感谢您的回答,但它不起作用...

onWindowVisibilityChanged

在我启动我的应用程序时调用一次。

onFocusChanged

函数从未被调用 ???

或者我做错了什么?这是我实现的代码...

protected void onWindowVisibilityChanged(int a)
{
int c = 0;

c+= 1;
}

protected void onFocusChanged(boolean b, int i , Rect rec)
{
int c = 0;

c += 1;
}

最佳答案

          Then you can use tabchanged event as shown below

tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
R.id.content_movies).setIndicator("",
getResources().getDrawable(R.drawable.menu_article)));
tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
new Intent(this, BS_Bars.class)).setIndicator("",
getResources().getDrawable(R.drawable.menu_bar)));
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

@Override
public void onTabChanged(String arg0) {
Bundle b=new Bundle();

if(arg0.equals("tab1"))
{

// write the code here to show the view


}

else if (arg0.equals("tab2")) {

// write the code here to show the view
}
});

关于android - Android中有没有像MFC中的onShow一样的布局功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4255441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com