LH Blog

在Android TextView上自訂超連結

超連結,像是這串字。我想在所有類型的app上很常見。不過要怎麼在Android上實做呢?我可以自定義點擊事件嗎? 首先,Android的TextView本身就支援超連結文本,來看看我們怎麼玩弄SpannableStringBuilder吧。 val builder = SpannableStringBuilder("Fancy String") builder.setSpan( object : ClickableSpan() { override fun o…

Continue Reading →

RecyclerView使用Decorator模式實做無項目提示

使用RecyclerView實做清單,在現在的原生Android app開發上已經成為一個必須。相較於ListView元件,RecyclerView提供了較高的效能以及動畫的支援。但是相較於ListView,RecyclerView沒有單純的setEmptyView(),我們必須將空清單提示的狀態實做在我們的Adapter內。不過等等,無項目提示其實實物上是很常見的功能。我們一定得每次都寫一次這個功能嗎?我們這裡使用Decorator模式來簡化這段實做 先看看結果吧 首先,我們有了一個清單實做 R…

Continue Reading →

Custom options for intent chosoer

In our day to day Android app development work. In most scenarios we have to provide action selection dialog for various Intent. Here is a alternative to custom a dialog, use a chooser Intent to create System provided selection dialog with custom selectio…

Continue Reading →

UI testing with CI

It is always a pain running automatic Android UI testing on CI Servers. Especially when we don`t have much resources for CI server to run a emulator. Here is our way to make it work. We have: A TeamCity Server at Remote Build Agent for building project a…

Continue Reading →

Handling orientation for scrolling position

Orientation is a common event which can be trigger easily by user. Handling orientation to keep the views states which increase user experiences, Users don`t need to do the same thing all the time after orientation. Here is a sample which handling orienta…

Continue Reading →