赞
踩
做了个按键的项目,有十六个按键,0-9,a,b,c,d,*,#
开始一个个设置按键麻烦死了,后来建了一个数组直接节省了一堆代码
Button button0,button1, button2, button3;
Button button4, button5,button6, button7;
Button button8, button9,buttonx, buttony;
Button buttona, buttonb, buttonc,buttond;
Integer[] id= new Integer[]{R.id.button0,R.id.button1,R.id.button2,R.id.button3,
R.id.button4,R.id.button5,R.id.button6,R.id.button7,
R.id.button8,R.id.button9,R.id.buttona,R.id.buttonb,
R.id.buttonc,R.id.buttond,R.id.buttonx,R.id.buttony};
Button[] buttons=new Button[]{button0,button1, button2, button3,
button4, button5,button6, button7,
button8, button9,buttona, buttonb,
buttonc, buttond,buttonx, buttony};
for(int x=0;x<=15;x++){
buttons[x]=(Button)findViewById(id[x]);
}
tb_nodeStatus = nodeStatusDAO.find(PubilcDefine.KEY);
}
很轻松的写完本来应该写的一大段代码嘿嘿
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。