08-26 Spinner、AutoCompleteTextView、GridView、Gallery、ExpandableListView

Spinner(下拉菜单)

//**layout_spinner.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <Spinner
        android:id="@+id/spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </Spinner>

</RelativeLayout>

//**Activity文件**
public class MainActivity extends Activity {
    private Spinner spinner;
    private ArrayAdapter<String> mAdapter;
    private String[] mDate={"mipmap_apple","mipmap_peach","mipmap_cherry","mipmap_banana","picture_melon","pictuer_game","angle"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        spinner= (Spinner) findViewById(R.id.spinner);
        mAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,mDate);
        spinner.setAdapter(mAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
![这里写图片描述](http://img.blog.csdn.net/20150826193516705)

AutoCompleteTextView(写出前几个字母,给出提示)

//**layout_autocompletetextview.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <AutoCompleteTextView
        android:id="@+id/autotexiview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@mipmap/search_tip"/>

</RelativeLayout>

//**Activity文件**
public class MainActivity extends Activity {
    private AutoCompleteTextView mAutoTextView;
    private ArrayAdapter<String> mAdapter;
    private String[] mDate={"mipmap_apple","mipmap_peach","mipmap_cherry","mipmap_banana","picture_melon","pictuer_game","angle"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mAutoTextView= (AutoCompleteTextView) findViewById(R.id.autotexiview);
        mAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,mDate);
        mAutoTextView.setAdapter(mAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
![这里写图片描述](http://img.blog.csdn.net/20150826194000918)

GridView(一行显示多列,多条数据)

//**layout_gridview.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <GridView
        android:id="@+id/gridview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numColumns="3"></GridView>

</RelativeLayout>

//**mygridview.xml**  view的模板
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">

    <ImageView
        android:id="@+id/imageview_grid"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@mipmap/apple"/>
    <TextView
        android:id="@+id/textview_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="苹果"/>

</LinearLayout>
![这里写图片描述](http://img.blog.csdn.net/20150826201508822)

//**Fruit类**
public class Fruit {
    private int  imageView;
    private String textView;
    private boolean isChecked;
    public Fruit(int imageView, String textView) {
        this.imageView = imageView;
        this.textView = textView;
    }

    public int getImageView() {
        return imageView;
    }

    public void setImageView(int imageView) {
        this.imageView = imageView;
    }

    public String getTextView() {
        return textView;
    }

    public void setTextView(String textView) {
        this.textView = textView;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setIsChecked(boolean isChecked) {
        this.isChecked = isChecked;
    }

}

//**MyGridAdapter类**
public class MyGridAdapter extends BaseAdapter{
    private List<Fruit> mFruits;
    private LayoutInflater mInflater;

    public MyGridAdapter(List<Fruit> mFruits, LayoutInflater mInflater) {
        this.mFruits = mFruits;
        this.mInflater = mInflater;
    }

    @Override

    public int getCount() {
        return mFruits.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView=mInflater.inflate(R.layout.mygridview,null);
            viewHolder.imageView= (ImageView) convertView.findViewById(R.id.imageview_grid);
            viewHolder.textView= (TextView) convertView.findViewById(R.id.textview_name);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }

        Fruit fruit=mFruits.get(position);
        viewHolder.imageView.setImageResource(fruit.getImageView());
        viewHolder.textView.setText(fruit.getTextView());
        return convertView;
    }
    class ViewHolder{
        ImageView imageView;
        TextView textView;
    }
}

//**Activity类**
public class MainActivity extends Activity {
    private Gallery gallery;
    private List<Fruit> mFruits;
    private LayoutInflater mInflater;
    private MyGalleryAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gallery= (Gallery) findViewById(R.id.gallery);
        mInflater=getLayoutInflater();
        mFruits=new ArrayList<>();
        for (int i = 0; i <10 ; i++) {
            Fruit apple = new Fruit(R.mipmap.apple,"苹果");
            Fruit banana = new Fruit(R.mipmap.banana,"香蕉");
            Fruit cherry = new Fruit(R.mipmap.cherry,"樱桃");
            Fruit peach = new Fruit(R.mipmap.peach,"桃子");
            mFruits.add(apple);
            mFruits.add(banana);
            mFruits.add(cherry);
            mFruits.add(peach);
        }
        mAdapter=new MyGalleryAdapter(mFruits,mInflater);
        gallery.setAdapter(mAdapter);
        gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Log.d("MyGallery","The fruit is:"+mFruits.get(position).getTextView());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
![这里写图片描述](http://img.blog.csdn.net/20150826202006784)

Gallery(横向显示、可滑动)

//图案相互之间可重叠,居于中间位置图案,实体显示,其余半透明
//**layout_gallery.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <Gallery
        android:id="@+id/gallery"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:spacing="-50dp"
        android:unselectedAlpha="0.5">

    </Gallery>


</RelativeLayout>

//**mygallery.xml**   view的模板
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <ImageView
        android:id="@+id/imageview_grid"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@mipmap/apple"/>
    <TextView
        android:id="@+id/textview_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="苹果"/>

</LinearLayout>
![这里写图片描述](http://img.blog.csdn.net/20150826194536132)

//**Fruit类**
public class Fruit {
    private int  imageView;
    private String textView;
    private boolean isChecked;
    public Fruit(int imageView, String textView) {
        this.imageView = imageView;
        this.textView = textView;
    }
    public int getImageView() {
        return imageView;
    }

    public void setImageView(int imageView) {
        this.imageView = imageView;
    }

    public String getTextView() {
        return textView;
    }

    public void setTextView(String textView) {
        this.textView = textView;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setIsChecked(boolean isChecked) {
        this.isChecked = isChecked;
    }

}

//**MyGalleryAdapter类**
public class MyGalleryAdapter extends BaseAdapter{
    private List<Fruit> mFruits;
    private LayoutInflater mInflater;

    public MyGalleryAdapter(List<Fruit> mFruits, LayoutInflater mInflater) {
        this.mFruits = mFruits;
        this.mInflater = mInflater;
    }

    @Override

    public int getCount() {
        return mFruits.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView=mInflater.inflate(R.layout.mygallery,null);
            viewHolder.imageView= (ImageView) convertView.findViewById(R.id.imageview_grid);
            viewHolder.textView= (TextView) convertView.findViewById(R.id.textview_name);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }

        Fruit fruit=mFruits.get(position);
        viewHolder.imageView.setImageResource(fruit.getImageView());
        viewHolder.textView.setText(fruit.getTextView());
        return convertView;
    }
    class ViewHolder{
        ImageView imageView;
        TextView textView;
    }
}

//**Activity类**
public class MainActivity extends Activity {
    private Gallery gallery;
    private List<Fruit> mFruits;
    private LayoutInflater mInflater;
    private MyGalleryAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gallery= (Gallery) findViewById(R.id.gallery);
        mInflater=getLayoutInflater();
        mFruits=new ArrayList<>();
        for (int i = 0; i <10 ; i++) {
            Fruit apple = new Fruit(R.mipmap.apple,"苹果");
            Fruit banana = new Fruit(R.mipmap.banana,"香蕉");
            Fruit cherry = new Fruit(R.mipmap.cherry,"樱桃");
            Fruit peach = new Fruit(R.mipmap.peach,"桃子");
            mFruits.add(apple);
            mFruits.add(banana);
            mFruits.add(cherry);
            mFruits.add(peach);
        }
        mAdapter=new MyGalleryAdapter(mFruits,mInflater);
        gallery.setAdapter(mAdapter);
        gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Log.d("MyGallery","The fruit is:"+mFruits.get(position).getTextView());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });



    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
![这里写图片描述](http://img.blog.csdn.net/20150826194929212)

ExpandableListView

//layout_expandablelistview.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <ExpandableListView
        android:id="@+id/expandablelistview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ExpandableListView>

</RelativeLayout>

//**item_clazz.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#55ff0000">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="        "/>
    <TextView
        android:id="@+id/textview_clazz_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/textview_clazz_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/textview_clazz_students"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

//**item_student.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/textview_student_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/textview_student_age"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/textview_student_sex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

//**Clazz类**
public class Clazz {
    private String clazzName;
    private String clazzNum;

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }

    private List<Student> students;

    public Clazz(String clazzNum, String clazzName) {
        this.clazzNum = clazzNum;
        this.clazzName = clazzName;
    }

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public String getClazzNum() {
        return clazzNum;
    }

    public void setClazzNum(String clazzNum) {
        this.clazzNum = clazzNum;
    }

}

//**Student类**
public class Student {
    private String stndentName;
    private String studentAge;

    public Student(String stndentName, String studentAge, String studentSex) {
        this.stndentName = stndentName;
        this.studentAge = studentAge;
        this.studentSex = studentSex;
    }

    private String studentSex;

    public String getStndentName() {
        return stndentName;
    }

    public void setStndentName(String stndentName) {
        this.stndentName = stndentName;
    }

    public String getStudentAge() {
        return studentAge;
    }

    public void setStudentAge(String studentAge) {
        this.studentAge = studentAge;
    }

    public String getStudentSex() {
        return studentSex;
    }

    public void setStudentSex(String studentSex) {
        this.studentSex = studentSex;
    }

}

//**MyExpandAdapter类**
public class MyExpandAdapter extends BaseExpandableListAdapter{
    private List<Clazz> mClazz;
    private LayoutInflater mInflater;

    public MyExpandAdapter(List<Clazz> mClazz, LayoutInflater mInflater) {
        this.mClazz = mClazz;
        this.mInflater = mInflater;
    }

    @Override
    public int getGroupCount() {
        return mClazz.size();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return mClazz.get(groupPosition).getStudents().size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groupPosition;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        ViewHolderClazz viewHolderClazz;
        if(convertView==null){
            viewHolderClazz=new ViewHolderClazz();
            convertView=mInflater.inflate(R.layout.item_clazz,null);
            viewHolderClazz.textViewClazzName= (TextView) convertView.findViewById(R.id.textview_clazz_name);
            viewHolderClazz.textViewClazzNum= (TextView) convertView.findViewById(R.id.textview_clazz_num);
            viewHolderClazz.textViewClazzStudents= (TextView) convertView.findViewById(R.id.textview_clazz_students);
            convertView.setTag(viewHolderClazz);
        }else{
            viewHolderClazz= (ViewHolderClazz) convertView.getTag();
        }

        Clazz clazz=mClazz.get(groupPosition);
        viewHolderClazz.textViewClazzName.setText(clazz.getClazzName());
        viewHolderClazz.textViewClazzNum.setText(clazz.getClazzNum());
        viewHolderClazz.textViewClazzStudents.setText(""+clazz.getStudents().size());
        return convertView;
    }
    class ViewHolderClazz{
        TextView textViewClazzName;
        TextView textViewClazzNum;
        TextView textViewClazzStudents;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        ViewHolderStudent viewHolderStudent=null;
        if(convertView==null){
            viewHolderStudent=new ViewHolderStudent();
            convertView=mInflater.inflate(R.layout.item_student,null);
            viewHolderStudent.textViewStudentName= (TextView) convertView.findViewById(R.id.textview_student_name);
            viewHolderStudent.textViewStudentAge= (TextView) convertView.findViewById(R.id.textview_student_age);
            viewHolderStudent.textViewStudentsSex= (TextView) convertView.findViewById(R.id.textview_student_sex);
            convertView.setTag(viewHolderStudent);
        }else {
            viewHolderStudent= (ViewHolderStudent) convertView.getTag();
        }
        Clazz clazz=mClazz.get(groupPosition);
        List<Student> students=clazz.getStudents();
        Student student=students.get(childPosition);
        viewHolderStudent.textViewStudentName.setText(student.getStndentName());
        viewHolderStudent.textViewStudentAge.setText(student.getStudentAge());
        viewHolderStudent.textViewStudentsSex.setText(student.getStudentSex());
        return convertView;
    }
    class ViewHolderStudent{
        TextView textViewStudentName;
        TextView textViewStudentAge;
        TextView textViewStudentsSex;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }
}

//Activity类
public class MainActivity extends Activity {
    private ExpandableListView mEListView;
    private List<Clazz> mClazzs;
    private MyExpandAdapter mAdapter;
    private LayoutInflater mInflater;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mEListView= (ExpandableListView) findViewById(R.id.expandablelistview);
        insertDate();
        mInflater=getLayoutInflater();
        mAdapter=new MyExpandAdapter(mClazzs,mInflater);
        mEListView.setAdapter(mAdapter);

    }

    private void insertDate() {
        mClazzs=new ArrayList<>();
        Clazz clazz1=new Clazz("201201","一班");
        List<Student> student1=new ArrayList<>();
        student1.add(new Student("张思","18","女"));
        student1.add(new Student("李斯","19","男"));
        student1.add(new Student("王武","20","男"));
        clazz1.setStudents(student1);
        mClazzs.add(clazz1);
        Clazz clazz2=new Clazz("201202","二班");
        List<Student> student2=new ArrayList<>();
        student2.add(new Student("张思","18","女"));
        student2.add(new Student("李斯","19","男"));
        student2.add(new Student("王武","20","男"));
        clazz2.setStudents(student2);
        mClazzs.add(clazz2);
        Clazz clazz3=new Clazz("201203","三班");
        List<Student> student3=new ArrayList<>();
        student3.add(new Student("张思","18","女"));
        student3.add(new Student("李斯","19","男"));
        student3.add(new Student("王武","20","男"));
        clazz3.setStudents(student3);
        mClazzs.add(clazz3);
        Clazz clazz4=new Clazz("201204","四班");
        List<Student> student4=new ArrayList<>();
        student4.add(new Student("张思","18","女"));
        student4.add(new Student("李斯","19","男"));
        student4.add(new Student("王武","20","男"));
        clazz4.setStudents(student4);
        mClazzs.add(clazz4);
        Clazz clazz5=new Clazz("201205","五班");
        List<Student> student5=new ArrayList<>();
        student5.add(new Student("张思","18","女"));
        student5.add(new Student("李斯","19","男"));
        student5.add(new Student("王武","20","男"));
        clazz5.setStudents(student5);
        mClazzs.add(clazz5);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
![这里写图片描述](http://img.blog.csdn.net/20150826202947644)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值