Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you have already added the buttons to the xml file why are you creating dynamic buttons instead inflate the view if you want to add the layout dynamically also when you dynamically add the buttons to the relative layout you must call addRule function to place them at right place </p> <p>just create objects of button and edittext refer the as you have refere your relative layout </p> <pre><code>relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout); </code></pre> <p>and use them.</p> <p>Edit----</p> <p>For that you must remove buttons from the xml layout and then create the buttons like you are doing it's prefect just one thing like this here </p> <pre><code>&lt;Button android:id="@+id/Button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 1"/&gt; &lt;EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" **android:layout_toRightOf="@+id/Button1"** /&gt; </code></pre> <p>to place this editText you must use addRule() function </p> <pre><code>EditText editText1 = new EditText(this); editText1.setId(1); layoutParams.addRule(RelativeLayout.RIGHT_OF, 0); relativeLayout.addView(editText1, layoutParams); layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams .addRule(RelativeLayout.RIGHT_OF, 0); </code></pre> <p>where 0 is your button's id also set the layout params too to the layout like </p> <pre><code>editText.setLayoutParams(layoutParams ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload