내 앱에는 2 개의 활동이 있으며, 첫 번째는 각 페이지에 목록이있는 작업 표시 줄이고, 두 번째는 설정 활동, 작업 표시 줄의 수 및 탭 수입니다. 모든 것은 작동하지만 마지막 일은 내가 할 수없는 일이다. 설정을하고 버튼을 클릭하면 첫 번째 활동으로 돌아갈 수있는 방법이다. 나는 의도를 전달하고 새로운 것으로 활동을 시작하고 싶지 않다. 왜냐하면 JSONRpc 클라이언트가 시작 됐고 연결하는 데 시간이 걸리기 때문에 성가신 일이다. 나는 finish() 두 번째 액티비티를 시도하고 setActionBar onResume()을 호출했다. 그러나 ist는 작업 중이다. 덕분에 .. heres는 일부 코드 :안드로이드 저장/다시로드 설정
첫번째 활동 : 당신이) (설정 작업을 완료 할 때
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Rubriky = ((HNapp) this.getApplication()).getRubriky();
count=((HNapp) this.getApplication()).getCount();
int catIndex = savedInstanceState == null ? 0 :savedInstanceState.getInt("catIndex", 0);
setUpActionBar(catIndex);
}
//my try
public void onResume(Bundle savedInstanceState){
super.onResume();
int catIndex = savedInstanceState == null ? 0 : savedInstanceState.getInt("catIndex", 0);
Rubriky = ((HNapp) this.getApplication()).getRubriky();
count=((HNapp) this.getApplication()).getCount();
setUpActionBar(catIndex);
}
//setting up actionbar
public void setUpActionBar(int selTab) {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
CABNavHan handler = new CABNavHan(this);
actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
int i;
for (i = 0; i < count; i++) {
actionBar.addTab(actionBar.newTab().setText(Rubriky[i]).setTabListener(handler));
}
actionBar.setSelectedNavigationItem(selTab);
actionBar.setDisplayUseLogoEnabled(true);
}
어떻게 액션 바를 업데이트 할 수 있습니까? –
"ActionBar actionBar;"를 사용하여 count (멤버 변수)를 정의하는 위치 근처에서 참조를 저장할 수 있습니다. 그런 다음 onResume – Syntax