摘一段代码:
public class ListItemProvider extends RecycleItemProvider {
private ArrayList<String> data = new ArrayList<>();
private AbilitySlice mSlice;
ListItemProvider(AbilitySlice abilitySlice) {
mSlice = abilitySlice;
for (int i = 0; i < 10; ++i) {
data.add("test" + i);
}
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Component getComponent(int position, Component convertView, ComponentContainer parent) {
Component component = LayoutScatter.getInstance(mSlice).parse(ResourceTable.Layout_list_item, null, false);
if (!(component instanceof ComponentContainer)) {
return null;
}
ComponentContainer rootLayout = (ComponentContainer) component;
Text leftText = (Text) rootLayout.findComponentById(ResourceTable.Id_left_content);
leftText.setText(String.valueOf(position));
Text rightText = (Text) rootLayout.findComponentById(ResourceTable.Id_right_content);
rightText.setText(data.get(position));
return component;
}
}
想起小学的时候。。。作业真的多啊
不论怎么说挺可以的了
1
kile 2020-10-15 16:10:58 +08:00
看着像 listView,但是可回收?
|
3
yukiww233 2020-10-15 16:34:13 +08:00
每个 api 都能对应上是为了方便你们迁移(狗头
|
5
Smash 2020-10-15 17:53:00 +08:00 2
虽然我快 1 年半没写过 Android 代码了,但是这不是 Adapter 吗?换个 Provider 的名字?
|
6
fansangg 2020-10-15 23:01:44 +08:00
说实话乍一看还没看出来是 adapter,毕竟可能 4 年没碰过 listview 了
所以 Component == View,RecycleItemProvider == Adapter |