content: package com.aishang5wpj.juheDemo.juhe02;
  
  import android.graphics.Color;
  import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v7.app.AppCompatActivity;
  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.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  import com.aishang5wpj.juheDemo.R;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * Created by wpj on 16/5/27下午2:51.
   */
  public class AppBarLayoutActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_appbarlayout);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          toolbar.setNavigationOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  onBackPressed();
              }
          });
  
          RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
          recyclerView.setAdapter(new MyAdapter());
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setHasFixedSize(true);
      }
  
      public static class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  
          private List<String> mItems;
  
          public MyAdapter() {
              mItems = new ArrayList<>();
              for (char i = 'a'; i <= 'z'; i++) {
                  mItems.add(String.valueOf(i));
              }
          }
  
          @Override
          public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
              View view = LayoutInflater.from(parent.getContext())
                      .inflate(android.R.layout.simple_list_item_1, parent, false);
              return new MyHolder(view);
          }
  
          @Override
          public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  
              MyHolder myHolder = (MyHolder) holder;
              myHolder.mTextView.setTextColor(Color.BLACK);
              myHolder.mTextView.setText(mItems.get(position));
          }
  
          @Override
          public int getItemCount() {
              return mItems.size();
          }
  
          private class MyHolder extends RecyclerView.ViewHolder {
  
              private TextView mTextView;
  
              public MyHolder(View itemView) {
                  super(itemView);
                  mTextView = (TextView) itemView.findViewById(android.R.id.text1);
              }
          }
      }
  }
  