I am 2 days old to Android Programming. I may be comitting a mistake at the core level. If this is the case, pardon.
I am trying to add a text box to a Relative Layout. When a button is clicked.
The method is bound to the button by the attribute android:onClick="method"
By doing the below.
public method (View view){
RelativeLayout vRL = (RelativeLayout)findViewById(R.layout.rLayout);
TextView vET = new TextView(this);
vET.setText("Text added to view.");
vET.setId(1);
vRL.addView(vET);
setContentView(R.layout.rLayout);
}
But I am getting a null pointer exception at vRL.addView(vET);
- what is it that I am doing wrong? -OR-
- Am I not adding the
TextViewelement properly?