Home > Mobile >  An activity in two frament couldn't load all the controls
An activity in two frament couldn't load all the controls

Time:05-14

I have two frament login password and verification code, each contains the following two controls
 @ Override 
Protected void onStart () {
Super. OnStart ();
/login/password.
Phone_p=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_phone_p);
The password/login/password
PSW=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_psw);
//login authentication code phone number
Phone_v=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_phone_v);
//login verification code verification code
Verification=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_verification);
}


Is the default password
 
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//the default password login page (fragments: 0)
SelectFragment (0);
}
//select display fragments
Private void selectFragment (int fragmentId) {
//get the Fragment manager
FragmentManager manager=getFragmentManager ();
//open a transaction
FragmentTransaction transaction=manager. BeginTransaction ();
//hide first Fragment
HideFragment (transaction);

If (fragmentId==0) {/login/password
FragmentNumber=fragmentId;
If (pwdFragment==null) {
PwdFragment=new PwdActivity ();
Transaction. The add (R.i d.f ragment_content pwdFragment);
} else {
Transaction. The show (pwdFragment);
}
} else if (fragmentId==1) {//login authentication code
FragmentNumber=fragmentId;
If (verificationFragment==null) {
VerificationFragment=new VerificationActivity ();
Transaction. The add (R.i d.f ragment_content verificationFragment);
} else {
Transaction. The show (verificationFragment);
}
}

//to commit the transaction
transaction.commit();
}

When I use the verification code fragments after switch login fragments can lead to app flash back, the problem in the following two controls is empty, how to solve?
//login authentication code mobile number 
Phone_v=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_phone_v);
//login verification code verification code
Verification=getFragmentManager (.) findFragmentById (R.i d.f ragment_content). The getView (). The findViewById (R.i d.i nput_verification);
  • Related