0
经过一些没有结果的研究后,我来到这里寻求一点帮助。Listview向下滚动问题
这里是我的问题:
一个ListView其中显示安装在我的设备上的应用(名称和图标)的列表。 显示应用程序,但当我滚动时,元素重叠。
这里是我的onCreate(活动):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
//
final ArrayList<ResolveInfo> list = (ArrayList<ResolveInfo>) pm
.queryIntentActivities(intent,
PackageManager.PERMISSION_GRANTED);
ApplicationsAdapter adapter = new ApplicationsAdapter(getApplicationContext(),R.id.lv_home, list, pm);
ListView lv = (ListView) findViewById(R.id.lv_home);
lv.setAdapter(adapter);
}
这里是我的自定义适配器:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolderListViewHome holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(
R.layout.list_item, parent, false);
holder = new ViewHolderListViewHome(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolderListViewHome) convertView.getTag();
}
final String text = mList.get(position).activityInfo.applicationInfo
.loadLabel(mPm).toString();
holder.applicationName = holder.getApplicationName();
holder.applicationName.setText(text);
final Drawable drawable = mList.get(position).activityInfo.applicationInfo
.loadIcon(mPm);
holder.applicationIcon = holder.getApplicationIcon();
holder.applicationIcon.setImageDrawable(drawable);
return convertView;
}
我想告诉你的照片,但我没有必要的声誉,元素滚动时简单重叠。
预先感谢您的帮助:)
嗨比尔,谢谢你的回答。我的ViewHolder不是静态的,我试图使它静态并以静态方式调用我的属性,但没有改变,元素仍然彼此重叠。 – Whyzx 2014-09-05 22:00:15