i have some xml layout file.this is a my xml layout source code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/rot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#ff0000" >
<ImageView
android:id="@+id/btn_categorry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="12dp"
android:background="@drawable/ic_launcher" />
</RelativeLayout>
i try to add new RelativeLayout programmatically,bellow my 'rot' layout.i wrote some code but i can't add new layout this is a my source
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RelativeLayout.LayoutParams parms = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
final RelativeLayout ll = new RelativeLayout(
getApplicationContext());
Button add_btn = new Button(getApplicationContext());
add_btn.setText("Click to add TextViiews and EditTexts");
ll.addView(add_btn);
parms.addRule(RelativeLayout.BELOW, R.id.rot);
ll.setLayoutParams(parms);
}
});
as i said i can't add layout.what am i doing wrong? if anyone knows solution please help me thanks