android - How to save the button that has been added dynamically in andriod? -


i had searched many similar questions , know how dynamic add button how can save can see when reopen app...

                linearlayout.layoutparams params = new linearlayout.layoutparams(                         linearlayout.layoutparams.match_parent,                         linearlayout.layoutparams.wrap_content);                 button btn = new button(mainactivity.this);                 linearlayout linaer = (linearlayout) findviewbyid(r.id.linearlayout1);                  btn.setid(count);                 final int id_ = btn.getid();                 btn.settext(edittext.gettext().tostring());                 **linaer.addview(btn, params);**                 button btns = ((button) findviewbyid(id_));                 btns.setonclicklistener(new view.onclicklistener() {                     public void onclick(view view) {                         intent = new intent();                         it.setclass(mainactivity.this, album_main.class);                         startactivity(it);                     } 

when create button keep flag of , when reopen app check flag. if matches condition create button want.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -