if (PullToRefreshGridView.MODE_PULL_DOWN_TO_REFRESH == mPullRefreshGridView.getCurrentMode()) {
Toast.makeText(MainActivity.this, “下拉刷新”, Toast.LENGTH_SHORT).show();
mPullRefreshGridView.onRefreshComplete();
} else if (mode == PullToRefreshGridView.MODE_PULL_UP_TO_REFRESH) {
// 加载更多
Toast.makeText(MainActivity.this, “上拉加载更多”, Toast.LENGTH_SHORT).show();
mPullRefreshGridView.onRefreshComplete();
}
}
};
}
adapter
package com.example.refreshgridview;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class GridViewAdapter extends BaseAdapter {
private List mList = new ArrayList();
private Context mContext;
public GridViewAdapter(Context context,List list) {
super();
this.mContext = context;
this.mList = list;
}
@Override
public int getCount() {
return mList.size();
}
@Override
public GridInfo getItem(int position) {
return mList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ChildHolderOne holder;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_grid_live_show, parent, false);
holder = new ChildHolderOne();
holder.tvTitle = (TextView)convertView.findViewById(R.id.title_tv);
convertView.setTag(holder);
} else {
holder = (ChildHolderOne) convertView.getTag();
}
final GridInfo gridInfo = mList.get(position);
if(gridInfo.isSelect() == true){
holder.tvTitle.setBackgroundColor(mContext.getResources().getColor(R.color.grays));
} else {
holder.tvTitle.setBackgroundColor(mContext.getResources().getColor(R.color.gray_max));
}
final String number = gridInfo.getTitle();
holder.tvTitle.setText(number);
return convertView;
}
class ChildHolderOne {
TextView tvTitle;
}
}
bean
package com.example.refreshgridview;
最后
赠送大家一套完整的Android学习资料吧。
以前一直是自己在网上东平西凑的找,找到的东西也是零零散散,很多时候都是看着看着就没了,时间浪费了,问题却还没得到解决,很让人抓狂。
后面我就自己整理了一套资料,还别说,真香!
资料有条理,有系统,还很全面,我不方便直接放出来,大家可以先看看有没有用得到的地方吧。
附上白嫖地址:《Android架构视频+BATJ面试专题PDF+学习笔记》
图片转存中…(img-ytM0rVlG-1643957771734)]
[外链图片转存中…(img-hc71n0Vv-1643957771735)]
[外链图片转存中…(img-fodBGhAX-1643957771736)]
[外链图片转存中…(img-TN0AAyJf-1643957771736)]
[外链图片转存中…(img-GGtwa78M-1643957771736)]