-1

I have spent days trying to work out how to do this and looking at several resources but cannot find the solution!

Basically i am trying to get a button (Button02) which is stored in DummySectionFragment of java file, to open up another xml page called fragment_sale_eggs once clicked on.

code for main activity with fragment containing button: http://pastebin.com/SS9b1pG8

code for xml containing button: http://pastebin.com/97WZJhPR

Any help would be appreciated, i am a novice at java and android so please be clear with the reply.

Thanks!

Rav
  • 121
  • 2
  • 3
  • 12

2 Answers2

1

Have your UI do a fragment transaction when a given button is pressed. For example, when the Activity loads, load the first fragment, but when the button is pressed, change fragments to the second UI. This allows you to maintain a structured workflow in your UI without any hackery.

http://developer.android.com/guide/components/fragments.html#Transactions

jsimon
  • 577
  • 6
  • 17
0

Perhaps the easiest way (but not recommended), is to call setContentView(R.layout. fragment_sale_eggs) when Button02 is clicked.

Also, here's a link to a similar StackOverflow question, with an answer follows a more recommended procedure.

Community
  • 1
  • 1