Skip to content

Instantly share code, notes, and snippets.

@ikuo
Created February 15, 2014 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikuo/9014713 to your computer and use it in GitHub Desktop.
Save ikuo/9014713 to your computer and use it in GitHub Desktop.
package my.android.project
import _root_.android.app.Activity
import _root_.android.os.Bundle
import uk.co.bigbeeconsultants.http.HttpClient
import java.net.URL
class MainActivity extends Activity with TypedActivity { activity =>
override def onCreate(bundle: Bundle) {
super.onCreate(bundle)
setContentView(R.layout.main)
findView(TR.textview).setText("Loading...")
thread.start
}
private val thread: Thread = new Thread(
new Runnable {
override def run {
val httpClient = new HttpClient
val response = httpClient.get(new URL("http://www.google.com/"))
activity.updateText(response.body.asString)
}
}
)
private def updateText(text: String) {
runOnUiThread(new Runnable {
override def run {
findView(TR.textview).setText(text)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment