我遇到顯示ListView
項的問題。當我刪除自己的條件時,所有東西都顯示正確,但是當我重新添加條件以使用戶看不到時,我的列表視圖最終會出現空白的地方/行,而我不知道如何修復它。哪裏不對?條件是否正確?帶有條件的ListView顯示空行
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ApplicationInfo entry = aListAppInfo.get(position);
View v = convertView;
// convertView
// recyklovace
if(v == null){
LayoutInflater inflater = LayoutInflater.from(aContext);
v = inflater.inflate(R.layout.layout_appinfo, null);
}else{}
//nahrat layout
ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);
TextView tvAppName = (TextView)v.findViewById(R.id.tvName);
TextView tvPkgName = (TextView)v.findViewById(R.id.tvPack);
chAppStat = (ToggleButton)v.findViewById(R.id.switch1);
chAppStat.setTag(entry.packageName);
chAppStat.setOnCheckedChangeListener(aListener);
if (aListAppInfo.get(position).packageName == aListAppInfo.get(position).loadLabel (aPackManager)
||((entry.packageName.equals("android"))
|| (entry.packageName.equals("com.android.systemui"))
|| (entry.packageName.equals("com.android.dreams.basic"))
|| (entry.packageName.equals("com.android.certinstaller"))
|| (entry.packageName.equals("com.android.defcontainer"))
|| (entry.packageName.equals("com.android.htmlviewer"))
|| (entry.packageName.equals("com.android.keychain"))
|| (entry.packageName.equals("com.android.location.fused"))
|| (entry.packageName.equals("com.android.providers.applications"))
|| (entry.packageName.equals("com.android.providers.userdictionary")))){
chAppStat.setVisibility(View.INVISIBLE);
}else{
chAppStat.setVisibility(View.VISIBLE);
}
ivAppIcon.setImageDrawable(entry.loadIcon(aPackManager));
tvPkgName.setText(entry.packageName);
tvAppName.setText(entry.loadLabel(aPackManager));
return v;
// navrat view
}
將其更改爲'View.GONE' – thepoosh