Http://blog.csdn.net/yanzi1225627/article/details/7802402Here is my previous summary. I want to use it this time. The strange thing is that you can switch from interface a to interface B, from interface B to interface. From A to B again. The final reason is that in the jum2b function, I used the setcontentview (R. layout. B) method instead of the instantiated view bview parameter. Here we will summarize the problem again:
Assume that there are two interfaces, A and B. The button in a is btn1, and the button in B is btn2. it is interface a at startup. then press the buttons btn1 and btn2 to switch to another interface.
1. The two buttons must be global variables. If they are final in the oncreate function, they should also work.
2. Define two view aview = NULL and view bview = NULL in the global variable, and then instantiate it with Inflater in oncreate.
3. Get two functions jump2b and jump2a. The parameters passed by setcontentview in these two functions are defined above.ViewParameters. Both views must be. Then, when findviewbyid is used, call (aview). findviewbyid.
4. Set the listener for btn1 in oncreate, call the jump2b method, instantiate btn2 in the jump2b method, and set the listener. Add a flag. You only need to set the listener once.
Note: The main point is that the parameters passed in by setcontentview are the views instantiated by Inflater. They are called (aview). findviewbyid () when the button is instantiated ().