1

I want to be able to get reference to a RelativeLayout in the same way as

RelativeLayout relative = (RelativeLayout)findViewById(R.id.relative);

but without setting the ContentView of the Activity. I think it may have something to do with Infalter? My ultimate aim is to get this and add it as a child view of a custom view object.

Onik
  • 19,396
  • 14
  • 68
  • 91
SamRowley
  • 3,435
  • 7
  • 48
  • 77

1 Answers1

3

Yes, you can use LayoutInflater. Example:

LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);    
View mv = inflater.inflate(R.layout.yourlayout, null);

And then you could...

RelativeLayout relative = (RelativeLayout)mv.findViewById(R.id.relative);
Nacho L.
  • 9,582
  • 2
  • 25
  • 25