content: package com.cjj.perseiandroid;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.support.v7.widget.DefaultItemAnimator;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  import com.cjj.PerseiLayout;
  
  public class MainActivity extends BaseActivity {
      private PerseiLayout perseiLayout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragment_list);
          initPerseiView();
          initbar();
      }
  
      private void initbar() {
          Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
          toolbar.setTitle("");
          toolbar.setLogo(R.drawable.menu);
      }
  
      private void initPerseiView() {
          perseiLayout = (PerseiLayout) this.findViewById(R.id.persei);
          RecyclerView recyclerView = new RecyclerView(this);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
          linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
          recyclerView.setLayoutManager(linearLayoutManager);
          recyclerView.setAdapter(new IconAdapter(this));
          perseiLayout.setHeaderView(recyclerView);
      }
  
      @Override
      protected void onPause() {
          super.onPause();
      }
  
      @Override
      protected void onResume() {
          super.onResume();
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
  
      public class IconAdapter
              extends RecyclerView.Adapter<IconAdapter.ViewHolder> {
  
  
          public int[] icons =
                  {
                          R.drawable.a1, R.drawable.a2, R.drawable.a3, R.drawable.a4, R.drawable.a5, R.drawable.a6, R.drawable.a7,
                  };
  
          public class ViewHolder extends RecyclerView.ViewHolder {
              public final ImageView mImageView;
  
              public ViewHolder(View view) {
                  super(view);
                  mImageView = (ImageView) view.findViewById(R.id.avatar);
              }
  
  
          }
  
          public IconAdapter(Context context) {
              super();
          }
  
          @Override
          public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
              View view = LayoutInflater.from(parent.getContext())
                      .inflate(R.layout.item, parent, false);
              return new ViewHolder(view);
          }
  
          @Override
          public void onBindViewHolder(final ViewHolder holder, final int position) {
              holder.mImageView.setImageResource(icons[position]);
              holder.mImageView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Toast.makeText(MainActivity.this, "you have select pos--->" + position, Toast.LENGTH_SHORT).show();
                      Toast.makeText(MainActivity.this, "Pretend to see beautiful special effects" , Toast.LENGTH_LONG).show();
                      perseiLayout.closeMenu();
                  }
              });
          }
  
          @Override
          public int getItemCount() {
              return icons.length;
          }
      }
  }
  