* [Android] Retrieve Socket io Data and Set Adapter 接受來自 Socket.io 的資訊,即時更新資訊
* Code Reference: Simple Chat Application(Client-Server) in Android
* Android - Reverse listview as message display
* ListView 聊天模式技巧
* Code Reference: Simple Chat Application(Client-Server) in Android
* Android - Reverse listview as message display
* ListView 聊天模式技巧
* <ListView> 的屬性
// 資料最下面是最新一筆
android:stackFromBottom="true"
// 就算有及時更新資訊也暫時不跳,讓使用者在看前面訊息的時候也不會被打斷
android:transcriptMode="disabled"
android:transcriptMode屬性 | Android Developer* [Android] Maintain ListView Position when Refreshing
* 在新增的時候,自動滑到最底
myListView.smoothScrollToPosition(myList.getCount() - 1);
最好同時也設置 myListView.setSelection(myList.getCount() - 1);(註: 若要使用 setSelection(), 就還要在前面多加一行 setSelect(true); )
以免 smoothScrollToPosition 失效(疑似是距離太遠就不會呼叫?)
@GiulioPiancastelli smoothScrollToPosition doesn't work because it's supposed to scroll by a small amount towards the desired position. That means that it won't work for long lists or even for items that are far by more than 100dp or so. The documentation isn't clear about it but that's how it actually works. You can probably find out more by checking the actual implementation code if you're interested.--
android:transcriptMode
android:cacheColorHint
android:divider
android:fadingEdge
android:scrollbars
android:fadeScrollbars
--
LinkedList
add(): 從 tail 新增資料push(): 從 head 新增資料
*Ref: ArrayList和LinkedList的用法区别
ArrayList 與 LinkedList 的差異
沒有留言 :
張貼留言