开发者

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 开发者_如何学Cclosed 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?


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.


Call close() on the SlidingDrawer.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜