...
- Create an Activity extending SmartRegisterSecuredActivity that holds up the main view, forms, and details fragments for register like this.
- Create a BaseFragment extending SecuredNativeSmartRegisterFragment that renders the beneficairy records in listview and manages paging and data entry forms as here
- Create a DetailFragment extending DetailFragment that shows all details associated with beneficiary like this. This is explained in details here.
1- Create Register Activity
The first step to register building is creating an activity that manages fragments, forms, details, and navigation. As mentioned above implement SmartRegisterSecuredActivity .
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class MyRegisterActivity extends SmartRegisterSecuredActivity {
@Override
public SecuredNativeSmartRegisterFragment makeBaseFragment() {
// Return a fragment which generates the list view i.e. main grid fragment. Example is given below
return new MyMainRegisterFragment(new FormController(this));
}
@Override
public DetailFragment getDetailFragment() {
// Fragment handling details view for list records. Example would be in section Details view
// Or return null if no details view is applicable
return new MyDetailFragment();
}
@Override
protected String[] buildFormNameList() {
// Return a list of form names which would participate in data collection from this register.
// These froms are added to assets and generated via xlsforms
List<String> formNames = new ArrayList<String>();
formNames.add("my_form1");
formNames.add("my_form2");
formNames.add("my_form3");
return formNames.toArray(new String[formNames.size()]);
}
@Override
public String postFormSubmissionRecordFilterField() {
// The field which filters out data on successful form submission to highlight the new/updated record.
// The field should be a valid non-null field in your xlsform and should identify record uniquely, otherwise multiple records would be highlighted
// Return null if no data needs to be highlighted
return "my_beneficiary_id_in_form_submission";
}
@Override
protected void onResumption() {
// Any custom tasks on Resumption of activity
}
} |