在inflatered LinearLayout中按ID获取元素

时间:2018-03-16 04:53:24

标签: java android android-linearlayout

如何在inflatered LinearLayout中按ID获取元素?

这是我的代码工作正常,我看到创建的子LinearLayouts。

LinearLayout root = (LinearLayout)findViewById(R.id.linearLayoutContainer);
LayoutInflater inflater;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

final int size = grandTotalStatsRespond.getStatZoneItems().size();
for (int j = 0; j < size; j++)
{
    StatZoneItem statZoneItem = grandTotalStatsRespond.getStatZoneItems().get(j);
    LinearLayout l = (LinearLayout) inflater.inflate(R.layout.loader_total_stat_item, null);

    // Here I need to find TableRow and TextView within LinearLayout  by its ID
    // and set values of statZoneItem object.                   

    root.addView(l);
}

1 个答案:

答案 0 :(得分:2)

试试这个

alsamixer