return null;
}
@Override
public long getItemId(int section, int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getSectionCount() {//header的数量
return 3;
}
@Override
public int getCountForSection(int section) {//子item的数量
return 15;
}
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {//普通item的getview方法
LinearLayout layout = null;
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflator.inflate(R.layout.list_item, null);
} else {
layout = (LinearLayout) convertView;
}
((TextView) layout.findViewById(R.id.textItem)).setText("Section " + section + " Item " + position);
return layout;
}
@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {//header的getview方法
LinearLayout layout = null;
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflator.inflate(R.layout.header_item, null);
} else {
layout = (LinearLayout) convertView;
}
((TextView) layout.findViewById(R.id.textItem)).setText("Header for section " + section);
return layout;
}
}
(二)解析:
要使用它 需要继承 SectionedBaseAdapter
重写adapter之中的 6个方法
-
public Object getItem(int section, int position);
-
public long getItemId(int section, int position);
-
public int getSectionCount();
-
public int getCountForSection(int section);
-
public View getItemView(int section, int position, View convertView, ViewGroup parent);
-
public View getSectionHeaderView(int section, View convertView, ViewGroup parent);
getItem(int section, int position); //section: header的位置数 ,position:普通item的位置数
getItemId(int section, int position); //获取item的id 第几个section的 position
getSectionCount(); //header的总数量
getCountForSection(int section); //普通 item 的总数量
getItemView(int section, int position, View convertView, ViewGroup parent);
// 普通item 加载view的方法 类似adapter中getview() 方法
getSectionHeaderView(int section, View convertView, ViewGroup parent);
// header item 加载view的方法 也类似adapter中getview() 方法
在使用的时候 可以使用hashmap 把list存起来 通过section 和 position 进行数据展示
也可以单独对section进行判断 展示不同的header
最后神兽镇楼
//┏┓ ┏┓
//┏┛┻━━━┛┻┓
//┃ ┃
//┃ ━ ┃
//┃ ┳┛ ┗┳ ┃
//┃ ┃
//┃ ┻ ┃
//┃ ┃
//┗━┓ ┏━┛
// ┃ ┃ 神兽保佑
// ┃ ┃ 代码无BUG!
// ┃ ┗━━━┓
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
总结
可以看出,笔者的工作学习模式便是由以下 「六个要点」 组成:
❝ 多层次的工作/学习计划 + 番茄工作法 + 定额工作法 + 批处理 + 多任务并行 + 图层工作法❞
希望大家能将这些要点融入自己的工作学习当中,我相信一定会工作与学习地更富有成效。
下面是我学习用到的一些书籍学习导图,以及系统的学习资料。每一个知识点,都有对应的导图,学习的资料,视频,面试题目。
**如:我需要学习 **Flutter的知识。(大家可以参考我的学习方法)
点击这里了解更多即可领取!
- Flutter 的思维导图(无论学习什么,有学习路线都会事半功倍)
- Flutter进阶学习全套手册
- Flutter进阶学习全套视频
tps://bbs.csdn.net/topics/618156601)即可领取!
- Flutter 的思维导图(无论学习什么,有学习路线都会事半功倍)
[外链图片转存中…(img-Ey0h80Wn-1710760881162)]
- Flutter进阶学习全套手册
[外链图片转存中…(img-dfOGWWgJ-1710760881162)]
- Flutter进阶学习全套视频
[外链图片转存中…(img-XghFgNtD-1710760881162)]
大概就上面这几个步骤,这样学习不仅高效,而且能系统的学习新的知识。