Nie wiem, czy uznasz to za łatwy sposób, ale spróbowałem następujących rzeczy.
Zdefiniuj widok, który chcesz przywrócić w swoim własnym języku XML (próbowałem z przyciskiem, grając z widoczność pola, tekst, ...)
button.xml
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/adminUser2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:text="@string/admin_user" />
Następnie w głównym układ określić punkt wstawiania
<LinearLayout
android:id="@+id/buttonInsertLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
/>
W swoim obciążeniem działalnością wgląd punktu wstawiania pomocą inflater
private Button admin;
@Override
protected void onResume() {
super.onResume();
admin = (Button)View.inflate(UserLoggin.this, R.layout.button, null);
ViewGroup insert = (ViewGroup)findViewById(R.id.buttonInsertLayout);
insert.addView(admin);
// ...
}
Później w swojej metodzie resetowania() możesz nadmuchać nową instancję widoku, opartą na treści XML i zastąpić zmodyfikowaną nową.
public void resetView() {
ViewGroup parent = (ViewGroup)admin.getParent();
int index = parent.indexOfChild(admin);
parent.removeViewAt(index);
// Inflate a fresh new View corresponding to the initial state of the view
Button adminSave = (Button)View.inflate(UserLoggin.this, R.layout.button, null);
parent.addView(adminSave, index);
}
Nadzieja to pomaga ...
Moje pytanie brzmi, czy istnieje prosty sposób przywrócić Widok do stanu pierwotnego XML, coś w rodzaju 'View.reset()'. Nie pytam, jak lub gdzie mogę programowo go zmienić. – wvdz