当前位置: 首页 > news >正文

国内好的设计网站推荐甘肃省建设厅官方网站造价总站

国内好的设计网站推荐,甘肃省建设厅官方网站造价总站,长沙百度seo,wordpress配置七牛云cdn我将Android控件的Button和Checkbox的学习知识总结一下和大家共享 在Android开发中#xff0c;按钮和复选框是非常常用的控件 Button控件的基本使用方法很简单#xff0c;在布局文件中使用Button既可以了#xff0c;或者在java代码#xff1a;Button button … 我将Android控件的Button和Checkbox的学习知识总结一下和大家共享 在Android开发中按钮和复选框是非常常用的控件 Button控件的基本使用方法很简单在布局文件中使用Button既可以了或者在java代码Button button  ButtonfindViewByIdR.id.button1; Checkbox也是一样的。 1、Button控件 按钮控件的最常见的是单击事件可以通过Button.setOnClickListener方法设置处理单机事件的监听器也可以在Button标签的android:onClick属性指定单击事件方法名。如果当前类实现了android.view.view.OnClickListener接口可以直接将this传入到setOnClickListener方法。 下面看例子 布局文件 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationvertical android:layout_widthfill_parentandroid:layout_heightfill_parent android:gravitycenter_horizontalButton android:idid/btnCommonButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text我的按钮1 /Button android:idid/btnImageButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text按钮android:gravitycenter android:backgrounddrawable/button1 / /LinearLayout java实现文件 public class Main extends Activity implements OnClickListener, OnTouchListener,OnFocusChangeListener, OnKeyListener {private int value 1;private Button imageButton;private Button commonButton;private View lastFocusview;Overridepublic void onClick(View view){Button button (Button) view;if (value 1 button.getWidth() getWindowManager().getDefaultDisplay().getWidth())value -1;else if (value -1 button.getWidth() 100)value 1;button.setWidth(button.getWidth() (int) (button.getWidth() * 0.1)* value);button.setHeight(button.getHeight() (int) (button.getHeight() * 0.1)* value);}Overridepublic boolean onKey(View view, int keyCode, KeyEvent event){ if (KeyEvent.ACTION_DOWN event.getAction()){view.setBackgroundResource(R.drawable.button3);}else if (KeyEvent.ACTION_UP event.getAction()){view.setBackgroundResource(R.drawable.button2);}return false;}Overridepublic void onFocusChange(View view, boolean hasFocus){if (hasFocus){imageButton.setBackgroundResource(R.drawable.button2);}else{imageButton.setBackgroundResource(R.drawable.button1);}}Overridepublic boolean onTouch(View view, MotionEvent event){if (event.getAction() MotionEvent.ACTION_UP){view.setBackgroundResource(R.drawable.button1);}else if (event.getAction() MotionEvent.ACTION_DOWN){view.setBackgroundResource(R.drawable.button2);}return false;}Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);commonButton (Button) findViewById(R.id.btnCommonButton);imageButton (Button) findViewById(R.id.btnImageButton);commonButton.setOnClickListener(this);imageButton.setOnClickListener(this);imageButton.setOnTouchListener(this);imageButton.setOnFocusChangeListener(this);imageButton.setOnKeyListener(this);} }也可以试试图文混排的按钮 布局文件 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationvertical android:layout_widthfill_parentandroid:layout_heightfill_parentLinearLayout android:orientationhorizontalandroid:layout_widthfill_parent android:layout_height120dpButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:drawableTopdrawable/star android:text按钮1 /Button android:layout_widthwrap_contentandroid:layout_heightwrap_content android:drawableBottomdrawable/starandroid:text按钮2 android:drawablePadding30dp /Button android:layout_widthwrap_contentandroid:layout_heightwrap_content android:drawableLeftdrawable/starandroid:text按钮3 /Button android:layout_widthwrap_contentandroid:layout_heightwrap_content android:drawableRightdrawable/starandroid:text按钮4 android:drawablePadding20dp //LinearLayoutButton android:idid/button android:layout_width200dpandroid:layout_height200dp android:layout_marginTop10dp / /LinearLayout java实现文件 public class Main extends Activity {Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);Button button (Button) findViewById(R.id.button);SpannableString spannableStringLeft new SpannableString(left);Bitmap bitmapLeft BitmapFactory.decodeResource(getResources(),R.drawable.image_left);ImageSpan imageSpanLeft new ImageSpan(bitmapLeft, DynamicDrawableSpan.ALIGN_BOTTOM);spannableStringLeft.setSpan(imageSpanLeft, 0, 4,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);SpannableString spannableStringRight new SpannableString(right);Bitmap bitmapRight BitmapFactory.decodeResource(getResources(),R.drawable.image_right);ImageSpan imageSpanRight new ImageSpan(bitmapRight);spannableStringRight.setSpan(imageSpanRight, 0, 5,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);button.append(spannableStringLeft);button.append(我的按钮);button.append(spannableStringRight);} }接下来介绍一下ImageButton图片按钮其实和普通按钮一样差别在与不用文本显示而是图片 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationhorizontal android:layout_widthfill_parentandroid:layout_heightfill_parentImageButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:srcdrawable/button1_1 /ImageButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:srcdrawable/button2_1 / /LinearLayout 这边补充介绍RadioButton选项按钮控件和ToggleButton开关状态按钮控件 pre namecode classhtml?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationvertical android:layout_widthfill_parentandroid:layout_heightfill_parentRadioGroup android:layout_widthwrap_contentandroid:layout_heightwrap_contentRadioButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text选项1 /RadioButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text选项2 /RadioButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text选项3android:drawableLeftdrawable/star android:drawableTopdrawable/circleandroid:drawableRightdrawable/star android:drawableBottomdrawable/circle android:drawablePadding20dp //RadioGroup /LinearLayout ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationhorizontal android:layout_widthfill_parentandroid:layout_heightfill_parentToggleButton android:layout_widthwrap_contentandroid:layout_heightwrap_content/ToggleButton android:idid/toggleButton android:layout_widthwrap_contentandroid:layout_heightwrap_content android:layout_marginLeft30dpandroid:textOff打开电灯 android:textOn关闭电灯 / /LinearLayout 2、Checkbox控件 Checkbox复选框控件在这里采用动态加载的方式在xml布局文件的根节点不仅可以像LinearLayoutRelativeLayout一样的ViewGroup也可以直接使用View下面采用Checkbox标签。 Checkbox.xml; ?xml version1.0 encodingutf-8? CheckBox xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:idid/checkbox android:layout_widthfill_parentandroid:layout_heightwrap_content /main.xml ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:orientationvertical android:layout_widthfill_parentandroid:layout_heightfill_parentButton android:idid/button android:layout_widthwrap_contentandroid:layout_heightwrap_content android:text确定 / /LinearLayoutjava文件 public class Main extends Activity implements OnClickListener {private ListCheckBox checkboxs new ArrayListCheckBox();Overridepublic void onClick(View view){String s ;for (CheckBox checkbox : checkboxs){if (checkbox.isChecked())s checkbox.getText() \n;}if (.equals(s))s 您还没选呢;new AlertDialog.Builder(this).setMessage(s).setPositiveButton(关闭, null).show();}Overridepublic void onCreate(Bundle savedInstanceState){String[] checkboxText new String[]{ 是学生吗, 是否喜欢Android, 买车了吗, 打算出国吗 };super.onCreate(savedInstanceState);LinearLayout linearLayout (LinearLayout) getLayoutInflater().inflate(R.layout.main, null);for (int i 0; i checkboxText.length; i){CheckBox checkbox (CheckBox) getLayoutInflater().inflate(R.layout.checkbox, null);checkboxs.add(checkbox);checkboxs.get(i).setText(checkboxText[i]);linearLayout.addView(checkbox, i);}setContentView(linearLayout);Button button (Button) findViewById(R.id.button);button.setOnClickListener(this);} }
http://www.w-s-a.com/news/524090/

相关文章:

  • 清丰网站建设费用网站建设的前途
  • 网站上那些兼职网页怎么做的北京网页
  • 桂林建站平台哪家好品牌设计公司宣传文案
  • 平面设计和建设网站的区别公司官网静态
  • h5网站建设+案例住房住房和城乡建设部网站
  • 建设股公司网站东莞建设网网上平台
  • 湖州吴兴建设局网站加强网站建设的
  • 茌平做网站公司专业商城网站建设报价
  • 网站结构图怎么画wordpress注册不发送件
  • 个人备案网站可以做论坛吗电商推广方式有哪些
  • 网站建设 自适应国内最近的新闻
  • 校园网站开发背景吴江网站建设公司
  • 网站开发工程师发展趋势山东省建设工程电子信息网站
  • 适合大学生创业的网站建设类型吉林省舒兰市建设银行网站
  • 呼和浩特网站建设哪家好培训学校加盟费用
  • 网站如何做友情链接有道云笔记WordPress
  • 贵阳企业网站建设制作赤峰浩诚网站建设公司
  • asp官方网站微信模板素材
  • wordpress 留言给站长发邮件做百度推广员赚钱吗
  • 北京建站公司做网站价格专门找人做软件的网站
  • 商务网站的特点ui软件界面设计
  • 广州个性化网站开发网站索引量是什么意思
  • 公司网站制作专业公司python做后台网站的多吗
  • 桂林建站平台哪家好给别人做网站怎么收取费用
  • python做网站显示表格用visual做的网站
  • 彩票网站建设需要什么聊城网站建设首选天成网络
  • 安徽建设工程网站wordpress标签云代码
  • 推荐佛山顺德网站建设手机网站建设域名空间
  • 电子商务网站建设策划书例子企业官网用什么cms系统
  • 网站栏目设计怎么写平面设计接单报价表