Eclipse Can't Find Android.Support.V4.Widget.Swiperefreshlayout

eclipse can't find android.support.v4.widget.SwipeRefreshLayout

So it turns out the library is in the following location

/android-sdk-macosx/extras/android/m2repository/com/android/support/support-v4/19.1.0

As opposed to the usual

/android-sdk-macosx/extras/android/support

Also I had to restart eclipse and go to Android SDK Manager over and over and over, until the 19.1.0 version shows up.

I hope this saves someone else some trouble.

how to import android.support.v4.widget.SwipeRefreshLayout in my project

=== Update ===

It seems support-v4 is not identical in your all projects. Just do one thing, make all support-v4 same (copy from one to other projects)

=== Update ===

There must be something wrong with library your dependency. Share more details so we can look into.

This is Google official sample for swipe to refresh layout:

https://github.com/googlesamples/android-SwipeRefreshListFragment

You can refer this.

Android - SwipeRefreshLayout import not found

To use SwipeRefreshLayout make sure you have updated Android Support Library. To check if it is updated follow below steps:

--> Open Eclipse

--> Go to Window-> Android SDK Manager.

--> In SDK Manager scroll down to bottom. Look for Android Support Library. If rev. is 19.1 then you are good to use SwipeRefreshLayout. If it is less than 19.1, then update Androd Support Library.

--> Once it is updated you can use SwipeRefreshLayout for new project. But you still cannot use SwipeRefreshLayout for existing projects.

Below are the steps to use SwipeRefreshLayout in existing project.

--> After updating Android Support Library, create new project.

--> Look for android-support-v4.jar in this project.

--> Copy android-support-v4.jar from new project and replace android-support-v4.jar of existing project with new project's android-support-v4.jar.

--> Now you can use SwipeRefreshLayout in existing project as well.

where to put android.support.v4.widget.SwipeRefreshLayout and how to implement it?

To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView. Remember that SwipeRefreshLayout only supports a single ListView or GridView child. - Add the SwipeRefreshLayout Widget

So, your activity_main.xml should be like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout
</LinearLayout>

Implementation:

public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{

private SwipeRefreshLayout swipeRefreshLayout

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

swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout);
swipeRefreshLayout.setOnRefreshListener(this);

//to change the color of the refresh indictor
swipeRefreshLayout.setColorScheme(getResources().getColor(R.color.yourcolor),
getResources().getColor(R.color.yourcolor),
getResources().getColor(R.color.yourcolor),
getResources().getColor(R.color.yourcolor));
}

@Override
public void onRefresh() {
//do something here
//setRefreshing(false) will hide the indicator
swipeRefreshLayout.setRefreshing(false);
}
}

Cannot access SwipeRefreshLayout in eclipse

It won't be available for the existing project. SwipeRefreshLayout will be available for all new projects.

To use it in existing project create new project and copy android-support-v4.jar from new project and replace this jar from your old project jar. After replacing android-support-v4.jar you can use SwipeRefreshLayout in your existing project as well.

Android Error inflating class SwipeRefreshLayout

You need to use a full package name for SwipeRefreshLayout:

<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ryan.brooks.fropllc.frop.app.whatsGoingOnFragment"
android:id="@+id/swipe_refresh_whats_going_on">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#343434"></ScrollView>

</android.support.v4.widget.SwipeRefreshLayout>


Related Topics



Leave a reply



Submit