SwipeRefreshLayout简单使用

SwipeRefreshLayout简单使用Activity:importjava.text.DateFormat;importjava.util.Date;importandroid.os.Bundle;importandroid.os.Handler;importandroid.support.v4.widget.SwipeRefreshLayout;importandroid.support

大家好,又见面了,我是你们的朋友全栈君。

Activity:

import java.text.DateFormat;
import java.util.Date;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.widget.TextView;
import android.app.Activity;

public class SwipeRefreshActivity extends Activity implements OnRefreshListener{

private SwipeRefreshLayout swipeRefreshLayout;
private TextView dateTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
        dateTv = (TextView) findViewById(R.id.date);
        swipeRefreshLayout.setOnRefreshListener(this);
    }
@Override
public void onRefresh() {

swipeRefreshLayout.setRefreshing(true);
(new Handler()).postDelayed(new Runnable() {


@Override
public void run() {

swipeRefreshLayout.setRefreshing(false);
Date date = new Date(System.currentTimeMillis());
dateTv.setText(DateFormat.getDateTimeInstance().format(date));
}
}, 3000);
}
}


布局文件:


<android.support.v4.widget.SwipeRefreshLayout xmlns:android=”http://schemas.android.com/apk/res/android”
    xmlns:tools=”http://schemas.android.com/tools”
    android:id=”@+id/refresh”
    android:layout_width=”match_parent”
    android:layout_height=”match_parent”
    tools:context=”.SwipeRefreshActivity” >

    <ScrollView
        android:layout_width=”match_parent”
        android:layout_height=”match_parent” >

        <LinearLayout
            android:layout_width=”match_parent”
            android:layout_height=”wrap_content”
            android:orientation=”vertical” >

            <TextView
                android:layout_width=”wrap_content”
                android:layout_height=”wrap_content”
                android:text=”下拉刷新以产生当前日期” />

            <TextView
                android:id=”@+id/date”
                android:layout_width=”wrap_content”
                android:layout_height=”wrap_content”
                android:text=”日期” />
        </LinearLayout>
    </ScrollView>

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



感觉还是第三方的好,系统控件在不同版本系统上运行效果相差很大!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152940.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Navicat15注册机生成的激活码不正确_在线激活2022.02.04

    (Navicat15注册机生成的激活码不正确)最近有小伙伴私信我,问我这边有没有免费的intellijIdea的激活码,然后我将全栈君台教程分享给他了。激活成功之后他一直表示感谢,哈哈~https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~CJM5…

    2022年4月1日
    63
  • 常用方法在Ubuntu安装pycharm失败的解决方法[通俗易懂]

    常用方法在Ubuntu安装pycharm失败的解决方法[通俗易懂]按常用方法(下载安装包再./pycharm.sh)安装失败,报warn:keymap“visualstudio”notfound,keymap“eclipse”notfound想不通为什么和这些ide有关,查了也没解决最后直接到Ubuntu自带的Ubuntusoftware下搜索pycharm下载,一次成功,不知道为什么这么简单有效的方法大家都不优先推荐。。。…

    2022年9月1日
    0
  • GoLand 2021.7.20 激活码【永久激活】

    (GoLand 2021.7.20 激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月20日
    71
  • ipfs矿机挖币是骗局(ipfs挖矿用什么网络)

    友情提示:Filecoin还没上线,任何打着Filecoin旗号说现在就能挖矿的都是骗纸!币圈人对挖矿这件事情上心还得要扯到比特币。2012年的时候,阿瓦隆的创始人开发了ASIC芯片,当时ASIC矿机一面世,平均一天可以挖到375枚比特币!你没有看错是375枚!按照当时的比特币价格计算,阿瓦隆一天的挖矿收入就是20万元型态人民币!赚的盆满钵满! 时光一去不复返,如今的比特币挖矿行业竞争已经进入白…

    2022年4月14日
    50
  • 一道线程同步面试题

    一道线程同步面试题

    2021年11月13日
    38
  • Eigen库要点「建议收藏」

    Eigen库要点「建议收藏」旋转矩阵,旋转向量,四元数关系如下:另外,初始化(赋值)变换矩阵T的方式为:Isometry3dTcw(rotation);//rotation可以是旋转矩阵,可以是四元数,可以是旋转向量Tcw.pretranslate(t);//添加平移向量//或者:Isometry3dTcw=Isometry3d::Identity()//如果没有直接初始化,先设为单位阵Tcw.pre…

    2022年10月19日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号