How do i add a rule to a View that is already in my layout?
My XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_layout_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mylifeinformationsharedsocial.SexAcivity" >
<ListView
android:id="@+id/list_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
I want to add layoutParams.addRule(RelativeLayout.BELOW,myView.getId());
But if i add the View again to the layout it gives me an IllegalStateException(obviously Haha).
So how do i do that?
EDIT
Java:
listView = (ListView) findViewById(R.id.list_view_id);
listView.setAdapter(myArrayAdapter);
layoutParams.addRule(RelativeLayout.BELOW,datePicker.getId());
relativeLayout.addView(listView,layoutParams);
It throws the Exception at the addView()
method