Advertisement
sergiomarquesmoura

Untitled

Jan 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. button.setOnClickListener(new View.OnClickListener() {
  2.             @Override
  3.             public void onClick(View view) {
  4.                 Thread thread = new Thread(new Runnable() {
  5.  
  6.                     @Override
  7.                     public void run() {
  8.                         weatherApi.getWeather(new WeatherListener() {
  9.  
  10.                             @Override
  11.                             public void onWeatherReceived(final int celsius) {
  12.                                 runOnUiThread(new Runnable() {
  13.                                     @Override
  14.                                     public void run() {
  15.                                         textView.setText("Current weather is " + celsius + "ΒΊC");
  16.                                     }
  17.                                 });
  18.                             }
  19.  
  20.                             @Override
  21.                             public void onWeatherError(Exception exception) {
  22.                                 textView.setText("Error getting current weather! Cause: " + exception.getMessage());
  23.                             }
  24.                         });
  25.                     }
  26.                 });
  27.                 thread.start();
  28.             }
  29.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement