• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get button which is in another xml file

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my main class.



i need to get the butting id which is not defined in R.layout.activity_main.xml file.Currently i am getting error for phone=(Button)findViewById(R.id.phone);.Because its definde in another xml file.can anyone help me.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only get a reference to a GUI element that is part of a view that is inflated. It doesn't sound as if that would be the case in your code.

What do you propose to do with a reference to a GUI element that doesn't (yet) exist?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic