Q:

Programmatically create and align an edittext to the right of a textview

I've built an Android application that programmatically creates a textview and an edittext on the UI when the user presses a button. Currently when you press the 'add' button the two fields are created but the edittext appears underneith the textview, i'd like the edittext to appear on screen aligned to the right of the textview like so:
[addbutton]
[textview][edittext]
[textview][edittext]
[textview][edittext]  
code:
private OnClickListener addForm() {

        return new OnClickListener() {

            @Override
            public void onClick(View v) {

                mLayout.addView(createNewTextView(numberString));
                mLayout.addView(createNewEditText(null));
                numberInt = Integer.parseInt(numberString);
                numberInt++;
                numberString = Integer.toString(numberInt);
            }
        };
    }
    // add textview
    private TextView createNewTextView(String text) {
        final TextView textView = new TextView(this);
        textView.setLayoutParams(lparams);
        textView.setText(text);
        return textView;
    }

    // add edittext
    private EditText createNewEditText(String text) {
        final EditText editText = new EditText(this);

        editText.setLayoutParams(lparams);
        editText.setText(text);
        return editText;
    }

REVISION 1:
OK so I've changed my code around a bit to what I think should work but the edittext is still appearing below, can anyone see where i'm going wrong or change my code around to make it work?
New code:
    private OnClickListener add() {

        return new OnClickListener() {

            @Override
            public void onClick(View v) {

                createNewTextView(numberString);

                numberInt = Integer.parseInt(numberString);
                numberInt++;
                numberString = Integer.toString(numberInt);
            }
        };
    }

    // add textview
    private void createNewTextView(String text) {

        final TextView textView = new TextView(this);

        textView.setLayoutParams(lparams);
        textView.setText(text);
        textView.setId(numberInt);

        mLayout.addView(textView);

        createNewEditText(textView);
    }

    // add edittext
    private void createNewEditText(TextView textView) {

        final EditText editText = new EditText(this);

        lparams.addRule(RelativeLayout.RIGHT_OF, textView.getId());
        editText.setLayoutParams(lparams);
        mLayout.addView(editText);

    }

REVISION 2:
All java and XML code below:
Java:
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
private LinearLayout mLayout;
private Button mButton;
private String numberString = "1";
private int numberInt = 1;
final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,     LayoutParams.WRAP_CONTENT);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mLayout = (LinearLayout) findViewById(R.id.linearLayout);
        mButton = (Button) findViewById(R.id.button);
        mButton.setOnClickListener(add());
        TextView textView = new TextView(this);
        textView.setText("New text");
    }

    private OnClickListener add() {

        return new OnClickListener() {

            @Override
            public void onClick(View v) {

                mLayout.addView(createNewTextView(numberString));
                mLayout.addView(createNewEditText(null));
                numberInt = Integer.parseInt(numberString);
                numberInt++;
                numberString = Integer.toString(numberInt);
            }
        };
    }

// add textview
    private TextView createNewTextView(String text) {

        final TextView textView = new TextView(this);

        textView.setLayoutParams(lparams);
        textView.setText(text);
        return textView;
    }

    // add edittext
    private EditText createNewEditText(String text) {

    final EditText editText = new EditText(this);

        editText.setLayoutParams(lparams);
        editText.setText(text);
        editText.setId(numberInt);

        int i = editText.getId();

        Toast toast= Toast.makeText(MainActivity.this,"edittext ID:" + i ,      Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, -100);
        toast.show();

        return editText;
    }
}

XML:
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/linearLayout">

<Button 
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Add+"
 />

</LinearLayout>

A:

Use RelativLayout and set Rule like android:layout_toRightOf="@+id/textview"

