简体   繁体   中英

Android Java Fragment Button save

I got 2 Fragments. In the first Fragment I got a button. How is it possible to duplicate the button on the second Fragment when the user click on it.

What do you mean by duplicating a Button ? If it means creating a Button with the same text or other layout attribute, you can create a method in the second Fragment, like createButton(String text, int color) , to add the button dynamically. When the button is clicked, find the second Fragment, cast it to the class of second Fragment and call the createButton method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM