Skip to content

Commit

Permalink
deploy: f7f3eaf
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Sep 26, 2024
1 parent fd2af8b commit e6e46ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ <h2 id="integrate-hotwire-native"><a class="anchor" href="#integrate-hotwire-nat
<p>Set up the app’s layout by opening <code>activity_main.xml</code> and replace the entire file with the following:</p>
<pre class="language-xml"><code class="language-xml"><span class="token prolog">&lt;?xml version="1.0" encoding="utf-8"?></span><br><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>androidx.constraintlayout.widget.ConstraintLayout</span><br> <span class="token attr-name"><span class="token namespace">xmlns:</span>android</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>http://schemas.android.com/apk/res/android<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">xmlns:</span>app</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>http://schemas.android.com/apk/res-auto<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">android:</span>layout_width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>match_parent<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">android:</span>layout_height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>match_parent<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><br><br> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>androidx.fragment.app.FragmentContainerView</span><br> <span class="token attr-name"><span class="token namespace">android:</span>id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>@+id/main_nav_host<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>dev.hotwire.navigation.navigator.NavigatorHost<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">android:</span>layout_width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>match_parent<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">android:</span>layout_height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>match_parent<span class="token punctuation">"</span></span><br> <span class="token attr-name"><span class="token namespace">app:</span>defaultNavHost</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>false<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span><br><br><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>androidx.constraintlayout.widget.ConstraintLayout</span><span class="token punctuation">></span></span></code></pre>
<p>Finally, open <code>MainActivity.kt</code> and replace the entire file with this code:</p>
<pre class="language-kotlin"><code class="language-kotlin"><span class="token keyword">class</span> MainActivity <span class="token operator">:</span> <span class="token function">HotwireActivity</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token keyword">override</span> <span class="token keyword">fun</span> <span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token operator">:</span> Bundle<span class="token operator">?</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token punctuation">)</span><br> <span class="token function">setContentView</span><span class="token punctuation">(</span>R<span class="token punctuation">.</span>layout<span class="token punctuation">.</span>activity_main<span class="token punctuation">)</span><br> <span class="token punctuation">}</span><br><br> <span class="token keyword">override</span> <span class="token keyword">fun</span> <span class="token function">navigatorConfigurations</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token function">listOf</span><span class="token punctuation">(</span><br> <span class="token function">NavigatorConfiguration</span><span class="token punctuation">(</span><br> name <span class="token operator">=</span> <span class="token string-literal singleline"><span class="token string">"main"</span></span><span class="token punctuation">,</span><br> startLocation <span class="token operator">=</span> <span class="token string-literal singleline"><span class="token string">"https://hotwire-native-demo.dev"</span></span><span class="token punctuation">,</span><br> navigatorHostId <span class="token operator">=</span> R<span class="token punctuation">.</span>id<span class="token punctuation">.</span>main_navigator_host<br> <span class="token punctuation">)</span><br> <span class="token punctuation">)</span><br><span class="token punctuation">}</span></code></pre>
<pre class="language-kotlin"><code class="language-kotlin"><span class="token keyword">import</span> android<span class="token punctuation">.</span>os<span class="token punctuation">.</span>Bundle<br><span class="token keyword">import</span> dev<span class="token punctuation">.</span>hotwire<span class="token punctuation">.</span>navigation<span class="token punctuation">.</span>activities<span class="token punctuation">.</span>HotwireActivity<br><span class="token keyword">import</span> dev<span class="token punctuation">.</span>hotwire<span class="token punctuation">.</span>navigation<span class="token punctuation">.</span>navigator<span class="token punctuation">.</span>NavigatorConfiguration<br><br><span class="token keyword">class</span> MainActivity <span class="token operator">:</span> <span class="token function">HotwireActivity</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token keyword">override</span> <span class="token keyword">fun</span> <span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token operator">:</span> Bundle<span class="token operator">?</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br> <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">onCreate</span><span class="token punctuation">(</span>savedInstanceState<span class="token punctuation">)</span><br> <span class="token function">setContentView</span><span class="token punctuation">(</span>R<span class="token punctuation">.</span>layout<span class="token punctuation">.</span>activity_main<span class="token punctuation">)</span><br> <span class="token punctuation">}</span><br><br> <span class="token keyword">override</span> <span class="token keyword">fun</span> <span class="token function">navigatorConfigurations</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token function">listOf</span><span class="token punctuation">(</span><br> <span class="token function">NavigatorConfiguration</span><span class="token punctuation">(</span><br> name <span class="token operator">=</span> <span class="token string-literal singleline"><span class="token string">"main"</span></span><span class="token punctuation">,</span><br> startLocation <span class="token operator">=</span> <span class="token string-literal singleline"><span class="token string">"https://hotwire-native-demo.dev"</span></span><span class="token punctuation">,</span><br> navigatorHostId <span class="token operator">=</span> R<span class="token punctuation">.</span>id<span class="token punctuation">.</span>main_nav_host<br> <span class="token punctuation">)</span><br> <span class="token punctuation">)</span><br><span class="token punctuation">}</span></code></pre>
<h2 id="run!"><a class="anchor" href="#run!"></a> Run!</h2>
<p>Click Run → Run ‘app’ to launch the app in the emulator. You should see the following screen in the emulator:</p>
<img src="/assets/android-hotwire-native-demo.png" class="border" width="600" alt="Hotwire Native demo app" />
Expand Down

0 comments on commit e6e46ac

Please sign in to comment.