0

I am very new to android programming, migrating over from iOS and I am having a hard time.

So, I have set up a new application in Eclipse IDE with a fixed tab and swipe navigation. So it appears to have created a ActionBar. However, I need to change the content of each page rather than it just telling me which tab I clicked.

I have been searching for this for about, 30-45 mins now, and I cannot find anything which makes any sense!

How can I attach a new XML file to a view?

Josh Boothe
  • 1,413
  • 4
  • 25
  • 40

1 Answers1

0

I think the code you are looking for is:

setContentView(R.layout.your_xml_file)

Make sure your xml file is in your res/layout folder in your project

As for your button listener, check this answer.

Community
  • 1
  • 1
Ozzy
  • 8,244
  • 7
  • 55
  • 95
  • Thanks for commenting, where abouts in the code would this go? – Josh Boothe Jun 17 '13 at 13:47
  • This is the java code which goes in your activity. If you want to change the view on a button click it would go into the button action method – Ozzy Jun 17 '13 at 13:48
  • P.S. I think you should read this doc top to bottom since you don't understand the basic structure of an android app: http://developer.android.com/reference/android/app/Activity.html – Ozzy Jun 17 '13 at 13:50
  • I get that part, I should have been more specific sorry, do I have to add an event handler to the actionbar? – Josh Boothe Jun 17 '13 at 13:53
  • @JoshBoothe you can use a universal OnClickListener for the View and switch between actions depending on which button ID was pressed – Ozzy Jun 17 '13 at 13:55