Android水平列表循环插入数据

来源:互联网 发布:穷人的生活 知乎 编辑:程序博客网 时间:2024/06/03 04:17
<HorizontalScrollView                  android:layout_width="fill_parent"               android:layout_height="wrap_content"            android:scrollbars="@null">                          <LinearLayout            android:id="@+id/writerlin"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:orientation="horizontal"                       >                    </LinearLayout>                      </HorizontalScrollView>  public void intwriter(int i) {writerstyle = (LinearLayout) nowinflater.inflate(R.layout.writer_style_icon, null);authorlin1 = (LinearLayout) writerstyle.findViewById(R.id.line1);authorlin2 = (LinearLayout) writerstyle.findViewById(R.id.line2);writer_name1 = (TextView) writerstyle.findViewById(R.id.writer_name1);writer_name2 = (TextView) writerstyle.findViewById(R.id.writer_name2);writerlin.addView(writerstyle);// writer_name.setText(authorArr.get(i).get("name").toString());if (i % 2 == 0) {writer_name2.setText(list.get(i).get("name").toString());authorlin2.setTag(i);} else {writer_name1.setText(list.get(i).get("name").toString());authorlin1.setTag(i);// writerArr.add(authorlin1);}}for (int i = 0; i < list.size(); i++) {intwriter(i);}

0 0