Use view to inflate multiple times

前端 未结 4 1011
Happy的楠姐
Happy的楠姐 2021-01-11 19:57

I have a some problem regarding inflating and re-using the same TextView.
Its like its trying to overwrite the same textview over and over again or something and it can

4条回答
  •  臣服心动
    2021-01-11 20:03

    Try this:

    View mainlayout = inflater.inflate(R.layout.days_monday_inflate, null);
    
    for (int i = 0; i < 10; i++) {
        row = new TableRow(this);
        View layout_number = inflater.inflate(R.layout.inflate_number, null);
        TextView number = (TextView) layout_number.findViewById(R.id.Number);
        number.setTag(i);
        number.setText(Integer.toString(i));
        row.addView(number);
    }
    

提交回复
热议问题