I am confused here.
What my program do:
- displays a view(main layout) that allows user to enter some values(contains TextViews, EdiTexts, a single Button)
- when button is pressed, it contacts server and fetches data (HTTP POST – uses AsyncTask & get result)
- now format this data(result from server) and display it in another layout(output layout)
- when user presses back button, it goes back to main page(main layout) so to allow user to enter new data and fetch output from server again
What I have done:
- i have created an activity called “MyApp”
- created two layouts – main & output
- created button handler code for “Submit” button (of main layout) to start AsyncTask and to do HTTP posting and fetching of data
- in onPostExecute(), i have written code to display output layout (
setContentView(R.layout.output);) and to create TextViews in it and setText to set text.
After reading some articles i find i have to use separate activity to display output. Pass data from fetch operation of my main activity to second activity(output activity) and format it there and write code for button click handler to get back to main activity.
To send data from main activity to output activity, i should use Bundle. Correct ? Is anything to take care other than this ? Please guide me.
1 Answer