views:

508

answers:

1

I have a LinearLayout View with a OnClickhandler and I want to add a View after the LinearLayout programatically when the OnClick event is fired.

public void onClick(View view) {
    LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout info = (LinearLayout) li.inflate(R.layout.infolayer, null);
    // view.addViewAfter(info)
}

info is the View i want to add. view is the View on which the click goes and after which I want to add info.

How can I do that?

A: 

Assuming you have a known amount of linearlayouts could you just place them inside the XML resource and mark them as 'GONE'. When the event occurs make them visible. When they are marked as gone they shouldnt be taking any screen space up.

steve
Yea, I already thought about this option but I don't want it to be in the XML. It has to be inserted by code.
Mannaz