This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

button problem

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a xml layout with three buttons and i assigned an activity to one of the buttons and it worked fine. When i went to do the second one i was confused about where in my class file i was suppose to add the code so i just made another one but it wouldnt work so my question is how do i assign those three button tasks in only one class file or do i do it a different way
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use all three button in the same class. Suppose you have 3 buttons with 3 different id as



then you can use inner class as
 
Alex Vandusen
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and how would i direct my three different buttons to three different xml layouts within that one class?
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to create three different xml layouts for the three buttons...and did you see the startActivity() method ..... it will help...it would be like..


Edit :

Alex Vandusen wrote:... one class?


My mistake...i didnt see that one class..thing...i think you can use ... setContentView(YOUR XML LAYOUT ID) method....You can specify the XML LAYOUT ID according to button click....every xml layout should have the button layout on top of it...(Ofcourse button layout is another xml layout)
 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic