Position a relative layout below a listview element
<pre><code>RelativeLayout item = (RelativeLayout)findViewById(R.id.catalogParent);

View child = getLayoutInflater().inflate(R.layout.detailedcatalog, null);

RelativeLayout.LayoutParams layoutParams = new
RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);

layoutParams.addRule(RelativeLayout.BELOW,view.getId());

item.addView(child, layoutParams);
</code></pre>

<p>Above is the code for placing a layout below a listview element. The view.getId() function is always returning a -1. The relative layout is being inflated programmatically during runtime.</p>

<pre><code>lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView&lt;?&gt; arg0, View view,
int position, long arg3) {
...}}
</code></pre>

<p>The view object is obtained from the onItemClick function. Can you please help me with this. Thanks in advance.</p>
