欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

写了个小框架,大家帮忙提提意见 Android

程序员文章站 2022-07-14 15:59:12
...
放到google code上了:
http://code.google.com/p/easy-android-utility/


Usage Example:
typical Android activity

public class AndroidWay extends Activity
{
        private Button btn1;
        private Button btn2;

        @Override
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                btn1 = (Button)this.findViewById(R.id.btn1);
                btn2 = (Button)this.findViewById(R.id.btn2);
                
                OnClickListener listener = new OnClickListener(){

                        @Override
                        public void onClick(View v)
                        {
                                switch(v.getId()){
                                case R.id.btn1:
                                        //do something
                                        break;
                                case R.id.btn2:
                                        //do something
                                        break;
                                }                               
                        }};
                btn1.setOnClickListener(listener);
                btn2.setOnClickListener(listener);
        }
}


written using EasyAndroid

public class EasyWay extends EasyActivity
{
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
        }

        @OnClick({R.id.btn1, R.id.btn2})
        private void doSometing(View v)
        {
                switch(v.getId()){
                case R.id.btn1:
                        //do something
                        break;
                case R.id.btn2:
                        //do something
                        break;
                }
        }
}

相关标签: Android