steve
steve

Reputation: 694

Dynamically modify the content of a Sliding Drawer

I would like to be able to change the content of a sliding drawer when the user clicks on a radio button . For example if user checks radio button "A" and then opens the sliding drawer , it contains 2 edit boxes and a spinner. After the sliding is closed if the user clicks radio button "B" and opens the slider again , now it contains a radio group and an edit text.

The sliding drawer is closed when the user presses the radio buttons.

Could someone suggest an idea in towards achieving this?

Upvotes: 2

Views: 1476

Answers (3)

Sean
Sean

Reputation: 1

Create an array and put the change in a touch event.

Upvotes: 0

jjNford
jjNford

Reputation: 5270

You will need your context the view your drawer resides in. Then do something like this

If clicked 'A':

ViewGroup newContent = (ViewGroup) view.findViewById(R.id.myDrawerContent);
currentContext.getLayoutInflater().inflate(R.layout.theNewLayoutForA, newContent);

If clicked 'B':

ViewGroup newContent = (ViewGroup) view.findViewById(R.id.myDrawerContent);
currentContext.getLayoutInflater().inflate(R.layout.theNewLayoutForB, newContent);

Essentially all you are doing is getting your Sliding Drawer content view and inflating the new content into it.

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1007276

Call close() on the SlidingDrawer.

Upvotes: 1

Related Questions