Android 具有特定片段的开放性活动
我有一个向导,我在每个屏幕上使用片段,在最后一个活动中,我有一个按钮,用于向用户发送设置上的可访问性,当用户返回到我的应用程序时,该按钮必须更改为其他按钮,问题是,当用户返回到我的应用程序时,按钮没有更改,因此我希望关闭活动并在最后一个片段上重新打开它,这样按钮就可以正确地进行更改 如何打开Android 具有特定片段的开放性活动,android,android-fragments,Android,Android Fragments,我有一个向导,我在每个屏幕上使用片段,在最后一个活动中,我有一个按钮,用于向用户发送设置上的可访问性,当用户返回到我的应用程序时,该按钮必须更改为其他按钮,问题是,当用户返回到我的应用程序时,按钮没有更改,因此我希望关闭活动并在最后一个片段上重新打开它,这样按钮就可以正确地进行更改 如何打开SecurityWizardFiveFragment()上的活动 我使用适配器设置片段的顺序: @Override public Fragment getItem(int position) {
SecurityWizardFiveFragment()上的活动代码>
我使用适配器设置片段的顺序:
@Override
public Fragment getItem(int position) {
switch(position)
{
case 0:
return new SecurityWizardOneFragment();
case 1:
return new SecurityWizardTwoFragment();
case 2:
return new SecurityWizardThreeFragment();
case 3:
return new SecurityWizardFourFragment();
case 4:
return new SecurityWizardFiveFragment();
}
return null;
}
我的安全向导活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.security_wizard_info_tab);
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs.
adapter = new SecurityWizardViewPagerAdapter(getSupportFragmentManager(),Titles,Numboftabs,this);
// Assigning ViewPager View and setting the adapter
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
// Assiging the Sliding Tab Layout View
tabs = (SlidingTabLayout) findViewById(R.id.tabs);
tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
// Setting Custom Color for the Scroll bar indicator of the Tab View
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
return getResources().getColor(R.color.tabsScrollColor);
}
});
//Setting the ViewPager For the SlidingTabsLayout
tabs.setViewPager(pager);
}
private void installShortcut() {
final Intent shortcutIntent = new Intent(getApplicationContext(), SecurityWizardActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
final Intent intent = new Intent();
intent.putExtra("duplicate", false);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher_lycos));
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
}
SecurityWizardFiveFragment,在这里我将用户发送到可访问性:
if(accesabilityIsActive){
ImageView accessibilitya = (ImageView) v.findViewById(R.id.accessibility);
accessibilitya.setImageResource(R.drawable.acces2);
accessibilitya.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivity(intent);
}
});
}
创建全局变量securityWizardPage
关于我的安全向导活动
pager.setCurrentItem(Globals.securityWizardPage);
然后,当我想打开特定片段时:
Globals.securityWizardPage = 4;
有什么问题?您没有任何问题请同时出示您的活动代码抱歉,现在就在那里