I want to add one view in different linear layout .. Here is my code::
EditProfileActivity::
LinearLayout editPageLayout;
LinearLayout editPageLayoutsave;
public void initViews() {
editPageLayout = (LinearLayout) findViewById(R.id.linearLayoutForEdit);
editPageLayoutsave=(LinearLayout) findViewById(R.id.linearLayoutForSave);
}
for (int i = 0; i < length; i++) {
Field field = fieldValuesArray.get(i);
count = count + 1;
int lastCoreFieldId = count++;
Log.i("TextviewID",""+textviewid);
View view1 = runTimeUiLibs.getRuntimeViewtext(field,
lastCoreFieldId,textviewid);
if (view1 != null) {
LinearLayout fieldAndPrivacyLayout = UtilityClass
.getLinearLayoutHorizontal(EditProfileActivity.this);
view1.setLayoutParams(layoutParamsBasic);
layoutParamsBasic.setMargins(10, 10, 10, 10);
fieldAndPrivacyLayout.addView(view1);
editPageLayout.addView(fieldAndPrivacyLayout);
}
View view = runTimeUiLibs.getRuntimeView(field,
lastCoreFieldId,textviewid);
textviewid++;
if (view != null) {
LinearLayout fieldAndPrivacyLayout = UtilityClass
.getLinearLayoutHorizontal(EditProfileActivity.this);
view.setLayoutParams(layoutParamsBasic);
layoutParamsBasic.setMargins(10, 10, 10, 10);
fieldAndPrivacyLayout.addView(view);
**editPageLayoutsave.addView(fieldAndPrivacyLayout);** //Here I got error that I cant use same view in different layout(to add runtimeView())
**editPageLayout.addView(fieldAndPrivacyLayout);**//If I remove this then I am getting output as shown in image
}
fieldMapList.put(String.valueOf(view.getId()), field);
}
}
Here is my xml File :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:background="@drawable/bg_light1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:id="@+id/edt_ll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayoutForEdit"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayoutForSave"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/icon_yma" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
I am creating one dynamic form which is generating from json file..In this, I have one layout which has Textview only and in second layout, different fields(EditText,Spinner,RadioGroup,Ratingbar) are generating...and I want of that selected (choosen) values and to save in database...
Right now getting this output:
I want output like :
Create your your_layout_file_to_resuse.xml
and use include
tag for resuse the tag
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background="@color/app_bg"
android:gravity="center_horizontal">
<include layout="@layout/your_layout_file_to_resuse"/>
.....
</LinearLayout>
see this link Re-Useing Layout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.