How to edit listview

kotlin · · 49 次点击    
<p>Can anyone point me in the right direction on how to edit listviews? E.g. edit the text in each row individually, as well as how to add or delete a whole row of the list?</p> <hr/>**评论:**<br/><br/>bbqburner: <pre><p>Android? Look for adapters e.g. <a href="" rel="nofollow">ArrayAdapter</a>, or the more recommended <a href="" rel="nofollow">RecyclerView</a>.</p> <p>That CodePath site also has a whole section on it: <a href="" rel="nofollow"></a></p></pre>KotlinN00b: <pre><p>Thanks for the link theres some good info in there. Specifically i want to edit the list/recyclerview while in the app. E.g. add in tasks for me to complete. Do you know anything which shows that?</p></pre>bbqburner: <pre><p>When it comes to adapters, its pretty much:</p> <ol> <li><p>what you do with your dataset </p></li> <li><p>notifying the adapter that the dataset its holding has changed.</p></li> </ol> <p>e.g. A view onClick will invoke <code>list.remove(item)</code> and then calling <code>adapter.notifyXchanged</code> where X can be <code>dataset</code>, <code>item</code> etc. Check the adapter you are using for its proper notify methods. If you need search terms, then <code>Android notify list/recycler adapter</code>. </p> <p>The default nuclear trigger is simply calling <code>adapter.notifyDataSetChanged</code>. For RecyclerView you can read <a href="" rel="nofollow">these</a> (also read using the DiffUtil below it). Also, this is not really Kotlin related and <a href="/r/androiddev" rel="nofollow">/r/androiddev</a> or StackOverflow is the proper avenue for this question.</p></pre>sneakpeekbot: <pre><p>Here&#39;s a sneak peek of <a href="/r/androiddev" rel="nofollow">/r/androiddev</a> using the <a href=";t=year" rel="nofollow">top posts</a> of the year!</p> <p>#1: <a href="" rel="nofollow">LPT: Drag up and down on process windows to accelerate gradle downloads</a> | <a href="" rel="nofollow">50 comments</a><br/> #2: <a href="" rel="nofollow">As a developer of a free game, people like this grind my gears</a> | <a href="" rel="nofollow">161 comments</a><br/> #3: <a href="" rel="nofollow">Kotlin is officially supported on Android</a></p> <hr/> <p><sup><sup>I&#39;m</sup></sup> <sup><sup>a</sup></sup> <sup><sup>bot,</sup></sup> <sup><sup>beep</sup></sup> <sup><sup>boop</sup></sup> <sup><sup>|</sup></sup> <sup><sup>Downvote</sup></sup> <sup><sup>to</sup></sup> <sup><sup>remove</sup></sup> <sup><sup>|</sup></sup> <a href="" rel="nofollow"><sup><sup>Contact</sup></sup> <sup><sup>me</sup></sup></a> <sup><sup>|</sup></sup> <a href="" rel="nofollow"><sup><sup>Info</sup></sup></a> <sup><sup>|</sup></sup> <a href="" rel="nofollow"><sup><sup>Opt-out</sup></sup></a></p></pre>Tired_Acrobat: <pre><p>Check this video : <a href="" rel="nofollow"></a></p></pre>KotlinN00b: <pre><p>Thanks for the link. Thats a good tutorial but it doesnt show how to edit the names of the list within the app? Do you know of anything which teaches that?</p></pre>Tired_Acrobat: <pre><p>You just add an item to the array and then call a methode that updates the list, like that :</p> <pre><code> yourArray.add(YourObject) yourRecyclerView.adapter.notifyDataSetChanged() </code></pre> <p>you can use this code in the onCreate() or anywhere you want , you just need to have access to yourArray and yourRecyclerView. And also if you want to show like int or strings there is no need to create a custom adapter or view handler.</p> <p>Finding a tutorial that explaining those things in Kotlin is hard, because the language is new (in the android world), but knowing how to read java will help you solve your problems because they use the same SDK. I actually found out how to do that by reading java code.</p></pre>
49 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet