Created
February 15, 2014 04:50
-
-
Save ikuo/9014713 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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