다음은 내 응용 프로그램 구조입니다. 4 개의 탭 (계정, 대시 보드, 미디어, 응용 프로그램)이있는 기본 활동이 있습니다. 각 탭은 활동과 연결됩니다. 응용 프로그램 탭에는 많은 액티비티가 포함되어 있으며, 탭을 계속 표시하기 위해 응용 프로그램 활동에서 if/else를 수행하여 표시해야하는 레이아웃을 알 수 있습니다 (아마도 가장 좋은 방법은 아니지만 더 나은 것을 찾지 못했을 것입니다).).TabLayout을 사용하여 활동을 캐시에 보관하지 마십시오.
내 문제 : 내 응용 프로그램 탭에 가서 모든 응용 프로그램 목록을보고 한 응용 프로그램을 클릭하면이 응용 프로그램에 대한 옵션이있는 새 화면이 나타나고 하나의 옵션을 클릭하면 새 화면 등 Medias 탭을 클릭하면 모든 Medias 목록이 나타납니다. 그런 다음 응용 프로그램 탭을 다시 클릭하면 특정 응용 프로그램의 옵션이 화면에 표시됩니다. 내가 원하는 것은 모든 응용 프로그램 목록으로 돌아가는 것입니다.
어떻게하면됩니까? 탭에 활동을 다시로드하고 캐시로 보이는 내용으로 가져 가지 않아야한다고 어떻게 알릴 수 있습니까?/다른 번들의 값에이() 된 setContentView로 사용하는 것을 레이아웃을 알고 있다면 난 그냥 이렇게 내 ApplicationsActivity에서
public class MainActivity extends TabActivity {
private int currentTab = 1;
private Application application = null;
private String optionType = null;
private String checkID = null;
private String alertID = null;
private int periodID = -1;
private Statistic stat = null;
private Media media = null;
TabHost tabHost;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
PreferencesManager.load(this);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
Log.i("IV", bundle.toString());
String applicationID = null;
applicationID = bundle.getString("applicationID");
if (applicationID != null) {
try {
this.application = Utils.getApplication(applicationID);
} catch (AuthenticationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ApiCallErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InternalErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
this.application = (Application) bundle
.getSerializable("application");
}
this.currentTab = bundle.getInt("currentTab", 1);
this.optionType = bundle.getString("optionType");
this.checkID = bundle.getString("checkID");
this.alertID = bundle.getString("alertID");
this.periodID = bundle.getInt("periodID", -1);
this.stat = (Statistic) bundle.getSerializable("stat");
this.media = (Media) bundle.getSerializable("media");
}
Log.i("IV", "current tab : " + currentTab);
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
//Log.i("IV", "Tab id : " +tabId);
setTabColor();
}
});
TabHost.TabSpec spec; // Resusable TabSpec for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
Intent intent = new Intent().setClass(this, AccountActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost
.newTabSpec("account")
.setIndicator(getString(R.string.account),
res.getDrawable(R.drawable.tab_account))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, DashboardActivity.class);
spec = tabHost
.newTabSpec("dashboard")
.setIndicator(getString(R.string.dashboard),
res.getDrawable(R.drawable.tab_dashboard))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, MediasActivity.class).putExtra(
"media", media);
spec = tabHost
.newTabSpec("medias")
.setIndicator(getString(R.string.medias),
res.getDrawable(R.drawable.tab_media))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ApplicationsActivity.class)
.putExtra("application", application)
.putExtra("optionType", optionType)
.putExtra("checkID", checkID).putExtra("alertID", alertID)
.putExtra("periodID", periodID).putExtra("stat", stat);
spec = tabHost
.newTabSpec("applications")
.setIndicator(getString(R.string.applications),
res.getDrawable(R.drawable.tab_application))
.setContent(intent);
tabHost.addTab(spec);
setTabColor();
if (!PreferencesManager.getBoolean("isLogged")) {
for (int i = 1; i < 4; i++) {
tabHost.getTabWidget().getChildTabViewAt(i).setEnabled(false);
tabHost.getTabWidget().getChildTabViewAt(i)
.setBackgroundColor(Color.rgb(102, 102, 102));
}
tabHost.setCurrentTab(0);
} else {
tabHost.setCurrentTab(currentTab);
}
}
public void setTabColor() {
for(int i=0;i<this.tabHost.getTabWidget().getChildCount();i++)
{
this.tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#000000")); //unselected
}
this.tabHost.getTabWidget().getChildAt(this.tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#ABABAB")); // selected
}
}
; 여기
내 주요 활동 코드대단히 감사합니다!
을하지만 난 뒤로 버튼이 작동하고 싶다. 그러나 어쨌든 당신을 감사하십시오. – Hooli