I have a custom view in my app that I draw using the onDraw() function in the View. Also it needs some data from the ACtivity to draw the graphic. So instead of using the standard setContentView(R.layout.myview) I am using the following –
MyView mv = new MyView(this, userData);
setContentView(mv);
This seemed to work until I added a textview above the customview. Then I realized that the above code does not show the textview at all. Also the onFinishInflate() is never called. Do I have to inflate the layout myself in this case? If so do I have to call the onDraw() function myself too?
Thanks,
– P
What you should have here is a layout that contains the
TextViewand yourMyViewand then inside your activity, find your custom view and pass in your user data. YourMyViewcan then use this during itsonDraw(). Perhaps something like this:res/layout/main.xml:src/my/package/MyView.java:src/my/package/MyActivity.java: