嘿我正在尝试查看网格视图中id小于100的特定项目。这是我的适配器类,但由于某种原因它无法工作并显示所有项目。 登录身份证,他们都很好。
public View getView(int position, View convertView, ViewGroup parent) {
PreviousViewHolder holder = null;
ServerFeed previousDayRank = getItem(position);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
if (previousDayRank.getId() < 100) {
convertView = layoutInflater.inflate(R.layout.popular_discover_list_item, null);
holder = new PreviousViewHolder(convertView);
convertView.setTag(holder);
} else {
convertView = layoutInflater.inflate(R.layout.null_item, null);
holder = new PreviousViewHolder(convertView);
convertView.setTag(holder);
}
} else {
holder = (PreviousViewHolder) convertView.getTag();
holder.setImageUrl(getContext(), previousDayRank.getName(), previousDayRank.getId());
}
return convertView;
}
答案 0 :(得分:0)
像这样更改你的getView方法
public View getView(int position, View convertView, ViewGroup parent) {
PreviousViewHolder holder = null;
ServerFeed previousDayRank = getItem(position);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.popular_discover_list_item, null);
holder = new PreviousViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (PreviousViewHolder)convertView.getTag();
}
if(previousDayRank.getId() < 100){
holder.setImageUrl(getContext(), previousDayRank.getName(), previousDayRank.getId());}
return convertView;
}
答案 1 :(得分:0)
只需在传递给addapter之前过滤您的数据。就像那样:
for(ServerFeed item : mServerFeeds){if(item.getId() > 100) mServerFeeds.remove(item);}
答案 2 :(得分:0)
在您的代码中调用此方法 -
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'FTP',
'path' => 'here i give path of folder',
'accessControl' => 'access' ,
'tmpPath' => '../files/ftp',// disable and hide dot starting files (OPTIONAL)
'defaults' => array('read' => true, 'write' => true),
'disabled' => array('rename', 'rm' , 'copy' ,'cut','paste')
)
)
);