当前位置:网站首页>Basic use of swiperefreshlayout, local refresh of flutterprovider

Basic use of swiperefreshlayout, local refresh of flutterprovider

2022-06-26 07:36:00 m0_ sixty-six million two hundred and sixty-five thousand and o

public class MainActivity extends AppCompatActivity {

private SwipeRefreshLayout swipeRefreshLayout;

@SuppressLint(“ResourceAsColor”)

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.layout);

SwipeRefreshLayout swip_refresh_layout=findViewById(R.id.swipeLayout);

swip_refresh_layout.setColorSchemeResources(R.color.colorPrimary);

}

 Insert picture description here

5.setProgressBackgroundSchemeResource(int coloRes), Set the background color of the drop-down progress

public class MainActivity extends AppCompatActivity {

private SwipeRefreshLayout swipeRefreshLayout;

@SuppressLint(“ResourceAsColor”)

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.layout);

SwipeRefreshLayout swip_refresh_layout=findViewById(R.id.swipeLayout);

swip_refresh_layout.setColorSchemeResources(R.color.colorPrimary); swip_refresh_layout.setProgressBackgroundColorSchemeColor(R.color.colorPrimaryDark);

}

 Insert picture description here

6.setRefreshing(boolean refreshing) Set refresh status ,false On behalf of stop execution

swip_refresh_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

@Override

public void onRefresh() {

new Handler().postDelayed(new Runnable() {

@Override

public void run() {

swip_refresh_layout.setRefreshing(false);

}

},2000);

}

});

 Insert picture description here

7. When it's all sorted out , Plus a couple of item, The complete code is as follows

package com.example.swiperefreshlayout;

import androidx.appcompat.app.AppCompatActivity;

import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import android.annotation.SuppressLint;

import android.os.Bundle;

import android.os.Handler;

import android.view.View;

import android.widget.ListView;

import android.widget.SimpleAdapter;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class MainActivity extends AppCompatActivity {

private SwipeRefreshLayout swipeRefreshLayout;

private String[] names = new String[]

{“Lion”,“Tiger”,“Monkey”,“Dog”,“Cat”,“Elephant”};

@SuppressLint(“ResourceAsColor”)

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.layout);

// establish list aggregate

ListView list = findViewById(R.id.aa);

List<Map<String,Object>> listItems =

new ArrayList<>();

for (int i=0;i<names.length;i++)

{

Map<String,Object> listItem =new HashMap<>();

listItem.put(“names”,names[i]);

listItems.add(listItem);

}

SimpleAdapter simpleAdapter=new SimpleAdapter(this,listItems,R.layout.item,

new String[]{“names”}

,new int[]{R.id.names});

list.setAdapter(simpleAdapter);

//SwipeRefreshLayout Function is introduced

final SwipeRefreshLayout swip_refresh_layout=findViewById(R.id.swipeLayout);

swip_refresh_layout.setColorSchemeResources(R.color.colorPrimary);

swip_refresh_layout.setProgressBackgroundColorSchemeColor(R.color.colorPrimaryDark);

swip_refresh_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

@Override

public void onRefresh() {

new Handler().postDelayed(new Runnable() {

@Override

public void run() {

swip_refresh_layout.setRefreshing(false);

}

},2000);

}

});

}

}

item.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:layout_width=“match_parent”

android:layout_height=“match_parent”>

<TextView

android:id="@+id/names"

android:layout_width=“match_parent”

android:layout_height=“70dp”

android:paddingLeft=“10dp”

android:layout_marginTop=“5dp”

android:textColor="@color/colorPrimaryDark"

android:textSize=“30dp” />

layout.xml

<?xml version="1.0" encoding="utf-8"?>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout

xmlns:android=“http://schemas.android.com/apk/res/android”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:orientation=“vertical”

summary

Finally, for programmers , What to learn 、 There's too much technology , If you want not to be eliminated by the environment, you have to constantly improve yourself , It's always us to adapt to the environment , Not the environment to adapt us !

Here are dozens of sets related to the above technical system diagram tencent 、 headlines 、 Ali 、 Meituan and other companies 2021 Interview questions for , Put the technical points into video and PDF( In fact, it took a lot more energy than expected ), contain The context of knowledge + A lot of details , Due to limited space , Here is a part of it in the form of pictures .

I believe it will bring you a lot of harvest :

Above 【 HD technology brain map 】 as well as 【 Supporting architecture technology PDF】 You can follow me for free

Android Study PDF+ Architecture video + Interview document + Source notes

(img-ZdavZF1h-1645006090792)]

Above 【 HD technology brain map 】 as well as 【 Supporting architecture technology PDF】 You can follow me for free

Android Study PDF+ Architecture video + Interview document + Source notes

It's easy to be a programmer , To be a good programmer is to keep learning , From junior programmer to senior programmer , From junior architect to senior architect , Or go to management , From technical manager to technical director , Each stage requires different abilities . Set your career direction early , In order to get rid of peers in work and ability improvement .

原网站

版权声明
本文为[m0_ sixty-six million two hundred and sixty-five thousand and o]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202171039585689.html