I have implemented an application for modify the xml layout with some properties.
I have designed an xml file at R.layout.main.
I am setting Visibility property from my activity class.When i update main.xml file at run time i would like to get copy of main.xml file with updated property as Visibility as gone
Initially the main.xml file as follows:
<?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" >
//Here i did not set the android:visibility=”gone”
//I would like to change the above property from activity class
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Question1" android:textColor="#ffffff"/>
<CheckBox
android:id="@+id/questioncheckBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/editTextone"
android:layout_width="180dip"
android:layout_height="wrap_content" android:focusable="true">
</EditText>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
I have implemented my application as follows:
public class ContentExmpleActivity extends Activity {
LinearLayout l1,l2;
CheckBox c1,c2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
l1 =((LinearLayout)findViewById(R.id.linearLayout1));
l2=((LinearLayout)findViewById(R.id.linearLayout2));
c1=((CheckBox)findViewById(R.id.checkBox1));
c2=((CheckBox)findViewById(R.id.checkBox2));
c1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
l1.setVisibility(View.GONE);
}
});
c2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
l2.setVisibility(View.GONE);
}
});
((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//Implementation for get the modified content xml layout with properties from emulator
}
});
}
}
from the above class i am hidding layout when user check the check box then it is hidding.When user click on save button i would like to get the contentView xml file as android layout xml.i mean copy of the main.xml with modified properties as hiding layout properties.
How can i get copy of main.xml file when the content has modified?
please any body help me…..
Replace
by
Now, you have a reference of your modified view and you can assign it where you want.