一)前言
今天我们一起来看一下进度载入条ProgressBarAndroid控件的解说与基本使用。
(二)使用介绍
ProgressBarAndroid控件使用起来相对来讲还是很easy的。首先我们来看一下官方的写的一个样例:
```java
import com.github.johnpersano.supertoasts.library.Style;
import com.github.johnpersano.supertoasts.library.SuperActivityToast;
import com.github.johnpersano.supertoasts.library.Style.COLOR_TYPE;
import com.github.johnpersano.supertoasts.library.Style.TEXT_TYPE;
import com.github.johnpersano.supertoasts.library.utils.ResourcesWrapper;
import com.google.android.material.tabs.TabLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager2.widget.ViewPager2;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private ViewPager2 viewPager2;
private TabLayout tabLayout;
private List
private List
private MyPagerAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initData();
}
private void initView() {
viewPager2 = findViewById(R.id.view_pager);
tabLayout = findViewById(R.id.tab_layout);
}
private void initData() {
titles = new ArrayList<>();
titles.add("首页");
titles.add("新闻");
titles.add("我的消息");
fragments = new ArrayList<>();
fragments.add(new HomeFragment());
fragments.add(new NewsFragment());
fragments.add(new MessageFragment());
adapter = new MyPagerAdapter(getSupportFragmentManager(), titles, fragments);
viewPager2.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager2);
}
}
```
但是大家细致看以上的代码会发现:这里面的标签怎么是ProgressBar呢?事实上官方文档这些写是有一点误导性的,假设你直接这样写,肯定会报错,查看官方Demo样例你会发如今该样例文件顶端须要引入ProgressBarAndroid组件例如以下:
```java
import com10143678589600759194imlib2demoactivitym10143678589600759194imlib2demosharedpreferencesm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm10143678589600759194imlib2demoutilsm1014367858960075