AndroidStudio 3.1.4
1.窗口组件的赋值方法(假设组件ID为liebiao)
1 TextView tv = (TextView)findViewById(R.id.liebiao); 2 tv.setText(textport);
2.for循环
1 for (int i = 0 ; i < 100 ; i++) { 2 3 } 4 for (int i = 0 ; i <= 100 ; i++) { 5 6 }
3.数组的定义
1 int[] num = {1,2,3,4,5,6,7} 2 String[] text = {"富强","民主","文明","和谐"}
4.信息框的使用
1 //定义一个新的对话框对象 2 AlertDialog.Builder alertdialogbuilder=new AlertDialog.Builder(this); 3 //设置对话框提示内容 4 alertdialogbuilder.setMessage("确定要退出程序吗?"); 5 //定义对话框2个按钮标题及接受事件的函数 6 alertdialogbuilder.setPositiveButton("确定",click1); 7 alertdialogbuilder.setNegativeButton("取消",click2); 8 //创建并显示对话框 9 AlertDialog alertdialog1=alertdialogbuilder.create(); 10 alertdialog1.show();
1 private DialogInterface.OnClickListener click1=new DialogInterface.OnClickListener() 2 { 3 @Override 4 public void onClick(DialogInterface arg0,int arg1) 5 { 6 //当按钮click1被按下时则取消操作 7 arg0.cancel(); 8 } 9 };
5.先写这些,Lucky~