java - Limited recreation of a button through a forloop -


so i'm building app each time floatactionbutton clicked, button created. aspect of app works fine. problem buttons being created on top of 1 , created. need create 4 buttons click after click, 1 below another.

this for-loop. appreciate help.

addingsemester.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 (int = 0; <= 4; i++){                     button semesterbutton = new button(mainactivity.this);                     semesterbutton.setid(i);                     semesterbutton.settext("semester " + i);                     semesterbutton.setlayoutparams(lp);                     semesterlayout.addview(semesterbutton);                     i++;                 }             }         }); 

xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout     android:id="@+id/main_layout"     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:background="#ffffff"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"     xmlns:app="http://schemas.android.com/apk/res-auto"     tools:context="myapp.onur.journeygpacalculator.mainactivity">      <!--<linearlayout-->         <!--android:layout_width="match_parent"-->         <!--android:layout_height="wrap_content"-->         <!--android:orientation="horizontal"-->         <!--android:padding="6dp"-->         <!--&gt;-->         <!--<button-->             <!--android:layout_width="wrap_content"-->             <!--android:layout_height="wrap_content"-->             <!--android:text="semester 1"-->             <!--android:layout_weight="4"-->             <!--android:textcolor="#ffffff"-->             <!--android:background="#3f51b5"-->             <!--/>-->         <!--<textview-->             <!--android:layout_width="wrap_content"-->             <!--android:layout_height="wrap_content"-->             <!--android:text="delete"-->             <!--android:layout_weight="0.6"-->             <!--android:clickable="true"-->             <!--android:textalignment="center"-->             <!--/>-->      <!--</linearlayout>-->           <android.support.design.widget.floatingactionbutton             android:id="@+id/addactionbutton"             android:layout_width="wrap_content"             android:layout_height="0dp"             android:layout_gravity="bottom|end"             android:layout_margin="16dp"             android:layout_weight="1"             android:clickable="true"             android:scaletype="fitxy"             android:src="@drawable/ic_add_black_24dp"             app:borderwidth="0dp"/>  </linearlayout> 


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -