Created
February 17, 2017 07:05
-
-
Save mumayank/b4e167f215832b7fcc24c167afa5e6e7 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
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
new CountClass().execute("name 1", "name 2", "name 3"); | |
} | |
class CountClass extends AsyncTask<String, String, String> { | |
protected String doInBackground(String... strings) { | |
for (int i=0; i<strings.length; i++) { | |
try { | |
Thread.sleep(1000); | |
publishProgress(strings[i]); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
return "done"; | |
} | |
protected void onProgressUpdate(String... progress) { | |
((TextView) findViewById(R.id.progressTextView)).setText(progress[0]); | |
} | |
protected void onPostExecute(String result) { | |
((TextView) findViewById(R.id.progressTextView)).setText(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment