Dynamically Created Buttons Have Same Label After Restarting Application?
I'm using a predefined button to generate new buttons when click on it. After generating new buttons I wish to change their label for that I'm using EditText defined in dialog box
Solution 1:
i see one problem in your code,
you write bellow code:
LayoutParamslp=newLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
finalButtonmyButton=newButton(this);
myButton.setText(prefs.getString(key+myButton.getId(),"New"));
you create one new button so this button don't have any id so how you want getId()
from that? this line retrieve nullnull
. because getid()
is null and key
is null too. you need change that code.
you try set Key of your button in SP with key+btn1.getId()
that key is null
, why you don't use btn1.getId()
as key in SP
?
and for retrieving your label just use i
in for statement.
Post a Comment for "Dynamically Created Buttons Have Same Label After Restarting Application?"