In your class, use the setOnRefreshListener
method by changing the contents of your TextView
. Just this:
SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
meuTextView.setText("Aqui o novo texto ao usar o swipe refresh");
swipeLayout.setRefreshing(false);
}
});
XML
Your .xml
might be something like this:
.
.
.
<!-- aqui suas outras views se houver-->
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- aqui suas outras views se houver-->
<TextView
android:id="@+id/meuTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jon Snow"
android:textSize="40dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<!-- aqui suas outras views se houver-->
</android.support.v4.widget.SwipeRefreshLayout>
See how to use SwipeRefreshLayout in in your application.