Hi,
I have the following problem: I've created a class that extends
RelativeLayout (not more or less) but when I try to add it to a
Linearlayout it is not shown. The strange thing to me is if I add a
"standard/normal RelativeLayout" it works. I checked this with
hierachyviewer, but the hierachyviewer shows exactly the same layouttree
except that the name of the node is different.
The first code excerpt is from the custom RelativeLayout class (namely
"ViewElement" that extends RelativeLayout) and the second shows how it's
done with the normal RelativeLayout class (here I haven't changed the
values of the textviews, but I guess this makes no difference):
*Code within the custom RelativeLayout class "ViewElement" to add a new
childview to a ViewElement:*
final RelativeLayout canvas = (RelativeLayout)
activity.findViewById(R.id.RelativeLayout);
inflater = LayoutInflater.from(activity);
final View childView = inflater.inflate(R.layout.textview1, canvas,
false);
LinearLayout listview = (LinearLayout)
canvas.findViewById(R.id.list_view);
TextView tValue = (TextView) childView.findViewById(R.id.test);
TextView tLabel = (TextView) childView.findViewById(R.id.test2);
tValue.setText(dataObj.getValue().toString());
tLabel.setText(dataObj.getName().toString());
listview.addView(this);
this.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
67));
this.addView(childView);
listview.setOrientation(LinearLayout.VERTICAL);
*Code that works with "normal RelativeLayout":*
final RelativeLayout canvas = (RelativeLayout)
> activity.findViewById(R.id.RelativeLayout);
>
> RelativeLayout xy = new RelativeLayout(activity);
>
> LayoutInflater inflater = LayoutInflater.from(activity);
> final View childView = inflater.inflate(R.layout.textview1, canvas,
> false);
>
> LinearLayout listview = (LinearLayout)
> canvas.findViewById(R.id.list_view);
>
> xy.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 67));
> listview.setOrientation(LinearLayout.VERTICAL);
> listview.addView(xy);
> xy.addView(childView);
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en