하나의 라이너 레이아웃으로 사용자 정의 상대 레이아웃을 추가 add_relative_layout.xml내가 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>
나는 Show_all.xml라는 이름으로 또 다른 안드로이드 XML 파일이 있습니다. 그것은 내가 내가이 코드를 사용하고이 SHOW_ALL 레이아웃 현재
에서 원하는만큼 이상이 상대적 레이아웃을 추가 할 선형 레이아웃 XML
입니다
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);
}
}
내가 널 포인트를 얻고있다 예외. 어떻게해야할지 말해줘.
안부
아래입니다. 우리가 당신을 대답하는 데 도움이되도록 logcat을 게시하십시오. – deepa
@umar 전체 logcat 넣고 NullPointerexception 당신에게 줄 줄. 귀하의 활동 중 어떤 줄이 Null이되는지 확인하십시오 –