Я сделал следующий относительный макет в XML-файле, скажем, add_relative_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/addAccountLinearLayout">
</LinearLayout>
Выше приведен основной макет, в который я хочу добавить копии файла кода ниже.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/UIContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white" >
<TextView
android:id="@+id/amountLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:text="Amount"
android:textColor="@android:color/black"
android:textStyle="bold" />
<EditText
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp" >
</EditText>
У меня есть другой XML-файл Android с именем Show_all.xml.Это линейный макет xml
Я хочу добавить этот относительный макет выше столько раз, сколько я хочу в этом макете show_all
В настоящее время я использую этот код
private void callOnCreate()
{
linear = (LinearLayout) findViewById(R.id.addAccountLinearLayout); // the layout in which i want to make dynamic copies of this layout.
layout = (RelativeLayout) findViewById(R.layout.ui_relative_layout_style); // name of xml File of above code.
for (int i=0; i < 4; i++)
{
Account account = accountArray.get(i);
linear.addView(layout, i);
}
}
Я получаю исключение нулевой точки.Подскажите пожалуйста что делать.
С наилучшими пожеланиями