Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Implementing Designs for Android Customizing a ListView for the Inbox Adding a Swipe-to-Refresh Gesture

Ribbit Design: Code Challenge

In the last part of the code challenge of Swipe Refresh Layout, wherein we end the refreshing, it looks like the Server's code executing engine has the old Android support library included because of which when I use isRefreshing method of SwipeRefreshLayout I get the following compiler error:

./MainActivity.java:21: cannot find symbol symbol : method isRefreshing() location: class android.support.v4.widget.SwipeRefreshLayout if(mRefreshLayout.isRefreshing()){

*********************************More comments******************* I am ending the refreshing inside the onRefresh() method of OnRefreshListener anonymous class by checking using the isRefreshing() method and then setting it to false if its true as suggested in the tutorial video.

Please help, Thanks!

2 Answers

Problem solved :)

In that challenge, I was being extra smart and completely copying Ben's video tutorial. All I was asked to do was to stop refreshing and I was checking unnecessarily whether it's refreshing or not with the isRefreshing() method and then setting it to false; which was the reason for failure but instead I had to just add setRefreshing(false);

Thanks anyways.

What is the Error in my code

        import android.os.Bundle;
                       import android.support.v4.widget.SwipeRefreshLayout;
                            import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;

public class MainActivity extends ListActivity {
public SwipeRefreshLayout mRefreshLayout;
  mRefreshLayout= (SwipeRefreshLayout)findViewById(R.id.refreshLayout);

    /*
     * Some code has been omitted for brevity
     */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public OnRefreshListener mOnRefreshListener = new OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Code that refreshes the content in the layout...
        }
    }; 
  mRefreshLayout.setOnRefreshListener(mOnRefreshListener);
 }