• Post Reply Bookmark Topic Watch Topic
  • New Topic

get button which is in another xml file

 
sam liya
Ranch Hand
Posts: 1246
  • 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: 42970
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?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!