Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Weather App Hooking Up the Model to the View I'm Feeling Refreshed

The app hangs up second time it gets refreshed when implemented with setOnClickListener.

I implemented onClick functionality using setOnClickListener like the below, but it allows me to refresh one time, but when I try again, the app hangs up, becomes non-responsive.

 private ImageView refreshImageView;
...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getForecast(latitude, longitude);

    refreshImageView = findViewById(R.id.refreshImage);
    refreshImageView.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
        refreshOnClick(view);
      }
    });

When using android:onClick="refreshOnClick", it works. I can refresh many times. I don't know why this happens.

Looking at logcat, I get

"2019-01-15 11:25:04.768 1961-1984/system_process I/GnssLocationProvider: WakeLock released by handleMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@e2bf1ec) "

many many times with verbose mode.