java - Automatic button creation when activity gets passed a string and icon -


i wondering how automatically create button when activity gets passed string , icon. have activity listening on port receive string , image computer. once image , string passed app, want app automatically create button using image background , string label under image.

i wondering if point me how start since not sure how start , having issues finding solutions online.

i wondering how position new button @ specific location on gui. want new button appear under button have in gui

public void createbutton (bitmap bitmap, string applicationname, layoutinflater inflater, viewgroup container){      view rootview = inflater.inflate(r.layout.home_fragment, container, false);      relativelayout rlayout = (relativelayout) rootview.findviewbyid(r.id.home_fragment);       button btn = new button(getactivity());     btn.settext(applicationname);      relativelayout.layoutparams params = new relativelayout.layoutparams(             relativelayout.layoutparams.wrap_content,             relativelayout.layoutparams.wrap_content);     params.addrule(relativelayout.right_of, app_row3_button3);     btn.setlayoutparams(params);      rlayout.addview(btn);     } 

here code far... method inside of class extends fragment (not activity). getting error "app_row3_button3", id of button want new button placed next to. existing button defined in class. error is:

wrong 2nd argument type. found: 'android.widget.imagebutton', required: 'int' 

add these lines , location depends on linearlayout position, make sure button in linearlayout lin

viewgroup linearlayout = (viewgroup) findviewbyid(r.id.lin);//lin linear layout id         bt.setlayoutparams(new viewgroup.layoutparams(viewgroup.layoutparams.fill_parent,                 viewgroup.layoutparams.wrap_content));         linearlayout.addview(bt); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -