Changes

Jump to: navigation, search
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<googlehtmlet>BUY_ANDROID_STUDIOandroidstudio</googlehtmlet>
== A Basic Threading Example ==
<googlehtmlet>ADSDAQBOX_FLOWadsdaqbox_flow</googlehtmlet>
The remainder of this chapter will work through some simple examples intended provide a basic introduction to threads. The first step will be to highlight the importance of performing time-consuming tasks in a separate thread from the main thread. Begin, therefore, by creating a new project in Android Studio, entering ThreadExample into the Application name field and ebookfrenzy.com as the Company Domain setting before clicking on the Next button.
A close inspection of the updated code for the buttonClick() method will reveal that the code to update the TextView has been removed. As previously stated, updating a user interface element from within a thread other than the main thread violates a key rule of Android development. In order to update the user interface, therefore, it will be necessary to implement a Handler for the thread.
<googlehtmlet>BUY_ANDROID_STUDIOandroidstudio</googlehtmlet>
== Implementing a Thread Handler ==
<googlehtmlet>BUY_ANDROID_STUDIOandroidstudio</googlehtmlet>
 
<htmlet>ezoicbottom</htmlet>
<hr>
<table border="0" cellspacing="0" width="100%">

Navigation menu