Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Everyone
Am developing an application with multiple XML files. When I receive particular commands from server, based on that i will be calling the required XML files using the command:

setContentView(R.layout.xml_file1);
setContentView(R.layout.xml_file2);

and this moves from xml_file1 to xml_file2...but I am unable to come back to previous screen ie xml_file1(its present screen)......whether is t correct to call xml file using the above mentioned command???
If not please suggest me the correct command....and also move back to the previous screen.....please help
Posted
Updated 23-Jan-14 2:39am
v2
Comments
Jayarajantk 23-Jan-14 2:16am    
<pre lang="java">setContentView(R.layout.xml_file1);
setContentView(R.layout.xml_file2);</pre>
inside your activity will be setting activity content view to xml_file2 layout only.
In order to move to another activity from current(from file1 to file2), you need to call an activity with Intent. Above code seems incorrect. Better search "Starting an activity from another".
User1454 23-Jan-14 4:00am    
thank u sir
Jayarajantk 5-Feb-14 23:07pm    
Any time, Varsha.
Krunal Rohit 23-Jan-14 8:39am    
Provide Java code of both files!

1 solution

Android uses Intent to transit between activities, see these examples :
simple-example-for-intent-and-bundle[^]
example_using_intent[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900