-4

How to show two activity in one window using java code(not use .xml code) in Android.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
adp
  • 1
  • 3
  • sir ,Can i use fargemet only .java file ,no use .xml file. – adp Aug 10 '13 at 05:05
  • i doubt there are other options , not sure but fragment can help you refer tuts – KOTIOS Aug 10 '13 at 05:08
  • I'd be very surprised if you *couldn't* create fragments in Java code. Ultimately, it's Java code that reads the xml file an lays out the application. – Edward Falk Aug 10 '13 at 06:29

1 Answers1

2

You can only call one activity at a time, but you have some options for displaying more than one "process" on the screen at the same time. Fragments are a common use for this: http://developer.android.com/guide/components/fragments.html From this link - "You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities."

You can also use toasts to display a message or prompt, splashes for a loading screen, etc.

If you tell me more about the two activities I can give you a more specific answer.

Casey Murray
  • 1,582
  • 17
  • 21
  • Be careful how you use the word "process". It has a completely different meaning to how you're using it. – Squonk Aug 10 '13 at 04:00
  • That's why I put quotations around it! I was having trouble finding a better word to describe what @adp is looking to do, since the question is vague. We java programmers have used a good bit of the English language to describe "stuff" and that makes it tough to find a word that doesn't have another use. Ha. =) – Casey Murray Aug 10 '13 at 04:04
  • Yeah I get that, but of all the words to use that could give people the wrong idea. Not sure I can think of a better word but you could re-phrase your answer to say something like "you can only have one Activity but it can have multiple Fragments" (leaving out the bit about "...displaying more than one "whatever" on the screen". – Squonk Aug 10 '13 at 04:27
  • sir ,Can i use fargemet only .java file ,no use .xml file. – adp Aug 10 '13 at 05:25
  • Can i use fargemet only .java file ,no use .xml file. – adp Aug 10 '13 at 05:32
  • Go check out http://stackoverflow.com/questions/5159982/how-do-i-add-a-fragment-to-an-activity-with-a-programmatically-created-content-v. This will show you how to add a fragment programatically (with Java instead of XML). – Casey Murray Aug 10 '13 at 06:46