|
3 | 3 | import android.os.Bundle;
|
4 | 4 | import android.support.annotation.Nullable;
|
5 | 5 | import android.support.v7.app.AppCompatActivity;
|
| 6 | +import android.support.v7.widget.GridLayoutManager; |
| 7 | +import android.support.v7.widget.RecyclerView; |
| 8 | +import android.view.View; |
| 9 | +import android.view.ViewGroup; |
| 10 | + |
| 11 | +import com.wang.avi.AVLoadingIndicatorView; |
6 | 12 |
|
7 | 13 | /**
|
8 | 14 | * Created by Jack Wang on 2016/8/5.
|
9 | 15 | */
|
10 | 16 |
|
11 | 17 | public class SampleActivity extends AppCompatActivity{
|
12 | 18 |
|
| 19 | + private RecyclerView mRecycler; |
| 20 | + |
13 | 21 | @Override
|
14 | 22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
|
15 | 23 | super.onCreate(savedInstanceState);
|
16 |
| - setContentView(R.layout.activity_loading); |
| 24 | + setContentView(R.layout.activity_sample); |
| 25 | + |
| 26 | + mRecycler= (RecyclerView) findViewById(R.id.recycler); |
| 27 | + |
| 28 | + GridLayoutManager layoutManager=new GridLayoutManager(this,4); |
| 29 | + mRecycler.setLayoutManager(layoutManager); |
| 30 | + mRecycler.setAdapter(new RecyclerView.Adapter<IndicatorHolder>() { |
| 31 | + @Override |
| 32 | + public IndicatorHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 33 | + View itemView=getLayoutInflater().inflate(R.layout.item_indicator,parent,false); |
| 34 | + return new IndicatorHolder(itemView); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public void onBindViewHolder(IndicatorHolder holder, int position) { |
| 39 | + holder.indicatorView.setIndicator(INDICATORS[position]); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public int getItemCount() { |
| 44 | + return INDICATORS.length; |
| 45 | + } |
| 46 | + }); |
| 47 | + } |
| 48 | + |
| 49 | + final static class IndicatorHolder extends RecyclerView.ViewHolder{ |
| 50 | + |
| 51 | + public AVLoadingIndicatorView indicatorView; |
17 | 52 |
|
| 53 | + public IndicatorHolder(View itemView) { |
| 54 | + super(itemView); |
| 55 | + indicatorView= (AVLoadingIndicatorView) itemView.findViewById(R.id.indicator); |
| 56 | + } |
18 | 57 | }
|
19 | 58 |
|
| 59 | + |
| 60 | + |
| 61 | + private static final String[] INDICATORS=new String[]{ |
| 62 | + "BallPulseIndicator", |
| 63 | + "BallGridPulseIndicator", |
| 64 | + "BallClipRotateIndicator", |
| 65 | + "BallClipRotatePulseIndicator", |
| 66 | + "SquareSpinIndicator", |
| 67 | + "BallClipRotateMultipleIndicator", |
| 68 | + "BallPulseRiseIndicator", |
| 69 | + "BallRotateIndicator", |
| 70 | + "CubeTransitionIndicator", |
| 71 | + "BallZigZagIndicator", |
| 72 | + "BallZigZagDeflectIndicator", |
| 73 | + "BallTrianglePathIndicator", |
| 74 | + "BallScaleIndicator", |
| 75 | + "LineScaleIndicator", |
| 76 | + "LineScalePartyIndicator", |
| 77 | + "BallScaleMultipleIndicator", |
| 78 | + "BallPulseSyncIndicator", |
| 79 | + "BallBeatIndicator", |
| 80 | + "LineScalePulseOutIndicator", |
| 81 | + "LineScalePulseOutRapidIndicator", |
| 82 | + "BallScaleRippleIndicator", |
| 83 | + "BallScaleRippleMultipleIndicator", |
| 84 | + "BallSpinFadeLoaderIndicator", |
| 85 | + "LineSpinFadeLoaderIndicator", |
| 86 | + "TriangleSkewSpinIndicator", |
| 87 | + "PacmanIndicator", |
| 88 | + "BallGridBeatIndicator", |
| 89 | + "SemiCircleSpinIndicator" |
| 90 | + }; |
| 91 | + |
20 | 92 | }
|
0 commit comments