刚开始研究了下鸿蒙 HAP,然后~ - V2EX
请不要在回答技术问题时复制粘贴 AI 生成的内容
DoodleSit

刚开始研究了下鸿蒙 HAP,然后~

  •  
  •   DoodleSit Oct 15, 2020 5039 views
    This topic created in 2039 days ago, the information mentioned may be changed or developed.

    摘一段代码:

     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; } } 

    想起小学的时候。。。作业真的多啊

    不论怎么说挺可以的了

    6 replies    2020-10-15 23:01:44 +08:00
    kile
        1
    kile  
       Oct 15, 2020
    看着像 listView,但是可回收?
    DoodleSit
        2
    DoodleSit  
    OP
       Oct 15, 2020
    @kile 没错,RecycleItemProvider 里有个 cache
    yukiww233
        3
    yukiww233  
       Oct 15, 2020
    每个 api 都能对应上是为了方便你们迁移(狗头
    kile
        4
    kile  
       Oct 15, 2020
    @DoodleSit 有 recyclerview 封装么,listview 不好使
    Smash
        5
    Smash  
       Oct 15, 2020   2
    虽然我快 1 年半没写过 Android 代码了,但是这不是 Adapter 吗?换个 Provider 的名字?
    fansangg
        6
    fansangg  
       Oct 15, 2020
    说实话乍一看还没看出来是 adapter,毕竟可能 4 年没碰过 listview 了

    所以 CompOnent== View,RecycleItemProvider == Adapter
    About     Help     Advertise     Blog     API     FAQ     Solana     3091 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 41ms UTC 02:55 PVG 10:55 LAX 19:55 JFK 22:55
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86