I have made a custom view that I’m setting inside the onCreate() method in the Main Activity.
Like this:
compassView = new CompassView(this);
setContentView(compassView);
My question is. How do I reference the view in xml, so I can put it inside a linearlayout together with other controls?
Assuming your
CompassViewis a class which is placed in the Package called ,com.android.sample
Create a XML like this,
And now as usual,
setContentView(R.layout.xmlname);in youronCreate().And
compassView = (CompassView)findViewbyId(R.id.compassview);