Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeEclipse
titleExample Register Initialization
public void setupViewsAndListeners() {
	Register myRegister = initRegister("View Permission For Register in OpenMRS", R.id.myRegisterContainer, R.id.btn_my_register, onRegisterStartListener,
        new RegisterCountView[]{
           new RegisterCountView(R.id.txt_my_count_type_1, "mybindType1", "", "B1", CountMethod.AUTO),
           new RegisterCountView(R.id.txt_my_count_type_2, "mybindType2", "", "B2", CountMethod.AUTO),
        });
}

// You can override count for a badge like below in method updateRegisterCounts
protected void updateRegisterCounts(HomeContext homeContext) {
    if (householdRegister.isAllowed()){ // TODO automate and call automatically without need to call resetCount
        householdRegister.resetRegisterCounts();

        int count1 = myRegister.getCountView(R.id.txt_my_count_type_1).getCurrentCount();
        int count2 = myRegister.getCountView(R.id.txt_my_count_type_2).getCurrentCount();

		// Actual count to display should be count1+count2 so override
        householdRegister.overrideRegisterCount(R.id.txt_my_count_type_2, count1+count2, "B2");
    }
}
Code Block
languagejava
themeEclipse
titleExample Home Activity

...