import{_ as o,r as t,o as i,c as r,b as s,d as e,a as n,e as l}from"./app--CGKFO0X.js";const p={},d=l('<h1 id="hikage-extension-betterandroid" tabindex="-1"><a class="header-anchor" href="#hikage-extension-betterandroid" aria-hidden="true">#</a> hikage-extension-betterandroid</h1><p><img src="https://img.shields.io/maven-central/v/com.highcapable.hikage/hikage-extension-betterandroid?logo=apachemaven&amp;logoColor=orange&amp;style=flat-square" alt="Maven Central"><span style="margin-left:5px;"></span><img src="https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fraw.githubusercontent.com%2FHighCapable%2Fmaven-repository%2Frefs%2Fheads%2Fmain%2Frepository%2Freleases%2Fcom%2Fhighcapable%2Fhikage%2Fhikage-extension-betterandroid%2Fmaven-metadata.xml&amp;logo=apachemaven&amp;logoColor=orange&amp;label=highcapable-maven-releases&amp;style=flat-square" alt="Maven metadata URL"><span style="margin-left:5px;"></span><img src="https://img.shields.io/badge/Min SDK-21-orange?logo=android&amp;style=flat-square" alt="Android Min SDK"></p>',2),c={href:"https://github.com/BetterAndroid/BetterAndroid",target:"_blank",rel:"noopener noreferrer"},h=l(`<h2 id="配置依赖" tabindex="-1"><a class="header-anchor" href="#配置依赖" aria-hidden="true">#</a> 配置依赖</h2><p>你可以使用如下方式将此模块添加到你的项目中。</p><h3 id="version-catalog-推荐" tabindex="-1"><a class="header-anchor" href="#version-catalog-推荐" aria-hidden="true">#</a> Version Catalog (推荐)</h3><p>在你的项目 <code>gradle/libs.versions.toml</code> 中添加依赖。</p><div class="language-toml line-numbers-mode" data-ext="toml"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#ADBAC7;">[</span><span style="color:#F69D50;">versions</span><span style="color:#ADBAC7;">]</span></span>
<span class="line"><span style="color:#ADBAC7;">hikage-extension-betterandroid = </span><span style="color:#96D0FF;">&quot;&lt;version&gt;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">[</span><span style="color:#F69D50;">libraries</span><span style="color:#ADBAC7;">]</span></span>
<span class="line"><span style="color:#ADBAC7;">hikage-extension-betterandroid = { module = </span><span style="color:#96D0FF;">&quot;com.highcapable.hikage:hikage-extension-betterandroid&quot;</span><span style="color:#ADBAC7;">, version.ref = </span><span style="color:#96D0FF;">&quot;hikage-extension-betterandroid&quot;</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在你的项目 <code>build.gradle.kts</code> 中配置依赖。</p><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#DCBDFB;">implementation</span><span style="color:#ADBAC7;">(libs.hikage.extension.betterandroid)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>请将 <code>&lt;version&gt;</code> 修改为此文档顶部显示的版本。</p><h3 id="传统方式" tabindex="-1"><a class="header-anchor" href="#传统方式" aria-hidden="true">#</a> 传统方式</h3><p>在你的项目 <code>build.gradle.kts</code> 中配置依赖。</p><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#DCBDFB;">implementation</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;com.highcapable.hikage:hikage-extension-betterandroid:&lt;version&gt;&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>请将 <code>&lt;version&gt;</code> 修改为此文档顶部显示的版本。</p><h2 id="功能介绍" tabindex="-1"><a class="header-anchor" href="#功能介绍" aria-hidden="true">#</a> 功能介绍</h2>`,13),y={href:"https://betterandroid.github.io/Hikage/KDoc/hikage-extension-betterandroid",target:"_blank",rel:"noopener noreferrer"},A=s("h3",{id:"适配器-adapter-扩展",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#适配器-adapter-扩展","aria-hidden":"true"},"#"),e(" 适配器 (Adapter) 扩展")],-1),m={href:"https://betterandroid.github.io/BetterAndroid/zh-cn/library/ui-component-adapter",target:"_blank",rel:"noopener noreferrer"},b=l(`<p>它使用了 BetterAndroid 提供的 <code>ViewHolderDelegate</code> 来创建扩展方法。</p><p>下面提供了一个基于 <code>RecyclerView</code> 的简单示例。</p><blockquote><p>示例如下</p></blockquote><div class="language-kotlin line-numbers-mode" data-ext="kt"><pre class="shiki github-dark-dimmed" style="background-color:#22272e;" tabindex="0"><code><span class="line"><span style="color:#768390;">// 假设这就是你需要绑定的数据集</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> listData </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">ArrayList</span><span style="color:#ADBAC7;">&lt;</span><span style="color:#F69D50;">MyEntity</span><span style="color:#ADBAC7;">&gt;()</span></span>
<span class="line"><span style="color:#768390;">// 创建并绑定到自定义的 RecyclerView.Adapter</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> adapter </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> recyclerView.</span><span style="color:#DCBDFB;">bindAdapter</span><span style="color:#ADBAC7;">&lt;</span><span style="color:#F69D50;">MyEntity</span><span style="color:#ADBAC7;">&gt; {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#DCBDFB;">onBindData</span><span style="color:#ADBAC7;"> { listData }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#DCBDFB;">onBindItemView</span><span style="color:#ADBAC7;">(</span></span>
<span class="line"><span style="color:#ADBAC7;">        Hikageable </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#DCBDFB;">TextView</span><span style="color:#ADBAC7;">(id </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;text_view&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">                text </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;Hello, World!&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                textSize </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">16f</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    ) { hikage, entity, position </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">        hikage.</span><span style="color:#DCBDFB;">get</span><span style="color:#ADBAC7;">&lt;</span><span style="color:#F69D50;">TextView</span><span style="color:#ADBAC7;">&gt;(</span><span style="color:#96D0FF;">&quot;text_view&quot;</span><span style="color:#ADBAC7;">).text </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> entity.name</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,4);function u(v,g){const a=t("ExternalLinkIcon");return i(),r("div",null,[d,s("p",null,[e("这是 Hikage 针对 "),s("a",c,[e("BetterAndroid"),n(a)]),e(" UI 组件相关功能的扩展依赖。")]),h,s("p",null,[e("你可以 "),s("a",y,[e("点击这里"),n(a)]),e(" 查看 KDoc。")]),A,s("p",null,[e("Hikage 为 BetterAndroid 提供的 "),s("a",m,[e("适配器"),n(a)]),e(" 提供了布局扩展功能，你可以直接在适配器的原始扩展方法上使用 Hikage 布局。")]),b])}const B=o(p,[["render",u],["__file","hikage-extension-betterandroid.html.vue"]]);export{B as default};
