Добавить вид к уже существующей xml группе просмотра в коде

Хотелось бы добавить вид к уже существующей xml-разметке в коде:

        LinearLayout ll = (LinearLayout) findViewById(R.layout.common_list);

        TextView tv = new TextView(this);
        tv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        tv.setText("sample text");
        ll.addView(tv);

        setContentView(ll); 

При создании новой LinearLayout в коде это работает, а при использовании Resource как в коде выше - нет.

common_list.xml:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="Quick List"/>

</LinearLayout>
5
задан Klau3 1 September 2011 в 13:25
поделиться