I have a class like that, and there are about 10 of them
public class DataItemPlainView extends View{
public DataItemPlainView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}}
Now I need to put TextView, ImageView etc inside this view. And when I call it from somewhere, I want to get my customView. setting a view to a custom layout is a case too.
Thanks
I would try extending some kind of Layout. Remember that (for the most part) they are also treated as Views. For more information/deciding which Layout to pick, try looking here:
http://developer.android.com/guide/topics/ui/layout-objects.html
Your custom view needs to extend
ViewGroup
or one of the other classes that extendsViewGroup
. For example, you could extend fromRelativeLayout
orLinearLayout
if those layouts fits what your custom view needs to do.Remember, even the layout classes are just another
View
. They just happen to have methods to add other views as children and have code to recursively measure and draw their children.