In your class, use the method setOnRefreshListener
by changing the content of your TextView
. That’s all:
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
may be something along those lines:
.
.
.
<!-- 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 more details here at how to use Swiperefreshlayouten in its application.
What you’ve already done?
– viana
As I did not know how this widget works. I prepared the whole XML.
– Joao