当前位置:网站首页>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);
}

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);
}

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);
}
});

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 .
边栏推荐
- Redis series - five common data types day1-3
- My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?
- item2安装配置及环境失效问题解决
- Encapsulating ranging and surface class based on leaflet
- PXRD, IR, TGA of two-dimensional porphyrin COF (POR COF) /cof (2D pdpor COF) - supplied by Qiyue
- Quickly find five channels for high-quality objects, quickly collect and avoid detours
- The difference between insert ignore and insert into
- Error: the specified LINQ expression contains a reference to a query associated with a different context
- $a && $b = $c what???
- ES cluster_block_exception read_only_allow_delete问题
猜你喜欢

安装homebrew报错汇总

Cloud native integration data warehouse heavy release

Young man, do you know the original appearance of kotlin association process?

Porphyrin based polyimide (ppbpis); Synthesis of crosslinked porphyrin based polyimides (ppbpi CRS) porphyrin products supplied by Qiyue biology

Calculate division in Oracle - solve the error report when the divisor is zero

Redis series - five common data types day1-3

3D porphyrin MOF (mof-p5) / 3D porphyrin MOF (mof-p4) / 2D cobalt porphyrin MOF (ppf-1-co) / 2D porphyrin COF (POR COF) / supplied by Qiyue

Liquid crystal texture diagram of purple solid mm-tpp-10c methacrylic acid decanoxy tetraphenyl porphyrin and mm-tpp-12c methacrylic acid dodecanoxy tetraphenyl porphyrin - Qi Yue display

【推荐10个 让你轻松的 IDEA 插件,少些繁琐又重复的代码】

Redis系列——5种常见数据类型day1-3
随机推荐
JS modularization
C implementation adds a progress bar display effect to the specified column of the GridView table in devaxpress - code implementation method
Here is the command to display the disk space usage. Go ahead and pay attention to more wonderful things!
Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue
Pycharm settings
Quickly find five channels for high-quality objects, quickly collect and avoid detours
Sanic based services use celery to complete dynamic modification timing tasks
Jemter 压力测试 -可视化工具支持-【安装篇】
I3wm get window class
Web technology sharing | webrtc recording video stream
Redis series - redis startup, client day1-2
How MySQL implements the RC transaction isolation level
Porphyrin based polyimide ppbpis (ppbpi-pa, ppbpi-pepa and ppbpi-pena); Crosslinked porphyrin based polyimide (ppbpi-pa-cr, ppbpi-pepa-cr, ppbpi-pena-cr) reagent
Thymeleaf中使用二维数组[[]]报错:Could not parse as expression
QT basics tutorial: qstring
Yyds dry inventory kubernetes easy service discovery and load balancing (11)
QPS
php array_ Merge details
The first screen time, you said you optimized it, then you calculated it and showed it to me!
C#/. Net phase VI 01C Foundation_ 02:vs2019 basic operations, excluding code files, smart tips, data types, differences between float and double, and differences between string and string