I have a spinner with the values = {4,5,6,7}
, initially spinner selected value is set to 4
, therefore 4 TextViews
and 4 EditTexts
showing in the activity.
Now I want if the user select value 5
from the spinner then these previous 4 TextViews
and EditTexts
will overwrite with new 5 TextViews
and 5 EditTexts
. How can I do so ? any help?
For this you can manage through loop like...
for( int i = 0; i < spinner.getSelectedItem(); i++)
{
TextView textView = new TextView(this);
textView.setText(textArray[i]);
linearLayout.addView(textView);
}
For create view one after another create programmatically layout like this:
LinearLayout linearLayout = new LinearLayout(this);
setContentView(linearLayout);
linearLayout.setOrientation(LinearLayout.VERTICAL)
Like this you can manage programmatically as per your need.
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.