前言:
本文收集整理了各大厂常见面试题N道,你想要的这里都有内容涵盖:Java 相关、Android 基础、Android Framework、三方源码、算法与数据结构、等技术栈,希望大家都能找到适合自己的公司,开开心心的撸代码。
dependencies {
implementation “androidx.swiperefreshlayout:swiperefreshlayout:1.0.0”
}
<?xml version="1.0" encoding="utf-8"?>第二步:编写布局文件
<LinearLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
<ListView
android:layout_width=“match_parent”
android:layout_height=“match_parent”/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
注意:这一步中,SwipeRefreshLayout必须包裹一个元素,要不然会报如下错误:空指针异常
好了,到这一步你就可以看到下拉刷新的雏形了
API的使用
======
设置下拉刷新进度条颜色
package com.wust.myswiperefresh;
import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//第一步:找到 swipeRefresh 控件
SwipeRefreshLayout srl_my_refresh = findViewById(R.id.srl_my_refresh);
//第二步,设置 下拉刷新时的颜色
srl_my_refresh.setColorSchemeColors(Color.parseColor(“#ff0000”),Color.parseColor(“#00ff00”));
}
}
设置下拉刷新背景色
package com.wust.myswiperefresh;
import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
总结:
面试是一个不断学习、不断自我提升的过程,有机会还是出去面面,至少能想到查漏补缺效果,而且有些知识点,可能你自以为知道,但让你说,并不一定能说得很好。
有些东西有压力才有动力,而学到的知识点,都是钱(因为技术人员大部分情况是根据你的能力来定级、来发薪水的),技多不压身。
附上我的面试各大专题整理: 面试指南,满满的都是干货,希望对大家有帮助!
能想到查漏补缺效果,而且有些知识点,可能你自以为知道,但让你说,并不一定能说得很好。
有些东西有压力才有动力,而学到的知识点,都是钱(因为技术人员大部分情况是根据你的能力来定级、来发薪水的),技多不压身。
附上我的面试各大专题整理: 面试指南,满满的都是干货,希望对大家有帮助!
[外链图片转存中…(img-QaKlnKmw-1649750437427)]