gpt4 book ai didi

android - 线性布局仅显示android中的最后数据

转载 作者:搜寻专家 更新时间:2023-11-01 07:51:05 26 4
gpt4 key购买 nike

我想将水平 ScrollView 与自定义线性布局 inflater 集成,所以我设置了以下代码

for (int i=0;i<mArrayListPersonDataLists.size();i++)
{
View child = getLayoutInflater().inflate(R.layout.row_pager_layout, null);
TextView mTextView1=(TextView)child.findViewById(R.id.row_txt_name);
TextView mTextView2=(TextView)child.findViewById(R.id.row_txt_email);
TextView mTextView3=(TextView)child.findViewById(R.id.row_txt_gender);
mLinearLayout.removeAllViews();
mTextView1.setText(mArrayListPersonDataLists.get(i).getName());
mTextView2.setText(mArrayListPersonDataLists.get(i).getEmail());
mTextView3.setText(mArrayListPersonDataLists.get(i).getGender());
mLinearLayout.addView(child);
}

在我的数组列表上方包含 9 个数据,但在屏幕上它只显示一个数据,所以知道我该如何解决这个问题吗?

最佳答案

你应该这样写这个函数

mLinearLayout.removeAllViews();
for (int i=0;i<mArrayListPersonDataLists.size();i++)
{
View child = getLayoutInflater().inflate(R.layout.row_pager_layout, null);
TextView mTextView1=(TextView)child.findViewById(R.id.row_txt_name);
TextView mTextView2=(TextView)child.findViewById(R.id.row_txt_email);
TextView mTextView3=(TextView)child.findViewById(R.id.row_txt_gender);
mTextView1.setText(mArrayListPersonDataLists.get(i).getName());
mTextView2.setText(mArrayListPersonDataLists.get(i).getEmail());
mTextView3.setText(mArrayListPersonDataLists.get(i).getGender());
mLinearLayout.addView(child);
}

关于android - 线性布局仅显示android中的最后数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34922472/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com