首页 > 解决方案 > 用于表格布局的 android 中的 ID 没有增加

问题描述

在下面的代码中,我动态显示从 1 开始的 ID 编号。但每次它只显示1。

谁能帮我解决这个问题?

for (GetRegisterdPatientListData getRegisterdPatientListData:getRegisterdPatientListDataArrayList) {

    RegistrationNo = getRegisterdPatientListData.getRegistrationNo();
    FName = getRegisterdPatientListData.getFName();
    LName = getRegisterdPatientListData.getLName();
    Mobile = getRegisterdPatientListData.getMobile();

    String[] RegistratonList = RegistrationNo.split(",");
    String[] Fnamelist = FName.split (",");
    String[] Lnamelist = LName.split (",");
    String[] Mobilelist = Mobile.split (",");
    numSlots = RegistratonList.length;

    for (int i = 0; i < numSlots; i++) {
        TableRow tbrow = new TableRow(getContext());
        tbrow.setLayoutParams(getLayoutParams());

        tbrow.addView(getTextView(i + numSlots, string.valueOf(i + 1), Color.BLACK, ContextCompat.getColor(getContext(), R.color.back_blue)));

        tbrow.addView(getTextView(i + numSlots, RegistratonList[i], Color.BLACK, ContextCompat.getColor(getContext(), R.color.back_blue)));

        tbrow.addView(getTextView(i + numSlots, Fnamelist[i].concat(" ").concat(Lnamelist[i]), Color.BLACK, ContextCompat.getColor(getContext(), R.color.back_blue)));

        tbrow.addView(getTextView(i + numSlots, Mobilelist[i], Color.BLACK, ContextCompat.getColor(getContext(), R.color.back_blue)));

        stk.addView (tbrow);

    }
}

标签: javaandroidandroid-tablelayout

解决方案


推荐阅读