zoukankan      html  css  js  c++  java
  • 关于初始化成员变量

    package jxnu.edu.cn.x3321;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.widget.ExpandableListAdapter;
    import android.widget.ExpandableListView;
    
    public class MainActivity extends Activity {
    
        //1.定义成员变量
        ExpandableListView elv;
        
        String [] group=new String[] {
                "Friends","Family","Teachers","Classmates"
        };
        String [][] members=new String[][] {
            {"Timi","Kimi","Cathy"},
            {"Lucy","Kaven","Hebe"},
            {"Selina","Ella","Bull"},
            {"Kerry","Mika","Mraz"},
        };
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            elv=(ExpandableListView)this.findViewById(R.id.elv);
            //自定义适配器
            Myela ela=new Myela(getApplicationContext(),group,members);
            //加载适配器
            elv.setAdapter(ela);
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }
    elv=(ExpandableListView)this.findViewById(R.id.elv);
    如果这句直接接在定义变量后面就会报错的!注意注意!
  • 相关阅读:
    jdk1.8新特性
    jdk1.7新特性
    jdk1.6新特性
    第十九课 pluginlib&Nodelet
    第十八课 Gazebo仿真器
    第十七课 导航实践(2)
    第十六课 导航实践(1)
    第十五课 导航基础
    十四课 slam&gmapping
    第十三课 Actionlib(2)
  • 原文地址:https://www.cnblogs.com/hishark/p/7550524.html
Copyright © 2011-2022 走看看