android整合--UI基本控件Button,ImageButton,EditText,ChcekBox,ToggleButton,RadioButton
来源:互联网 发布:golang程序员工资 编辑:程序博客网 时间:2024/05/31 18:32
写了几个基本控件
- Button
- ImageButton
- EditText
- CheckBox
- RadioGroup和RadioButton
- ToggleButton
下面是代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <ImageButton android:text="ImageButton" android:id="@+id/buttonimage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"> </ImageButton> <EditText android:id="@+id/edit1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <CheckBox android:id="@+id/check1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Autosave" /> <CheckBox android:id="@+id/checkstar" style="?android:attr/starStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioGroup android:id="@+id/grou1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <RadioButton android:id="@+id/radio1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="option1" > </RadioButton> <RatingBar android:id="@+id/ra1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numStars="4" android:rating="2" > </RatingBar> </RadioGroup> <ToggleButton android:id="@+id/toggole1" android:layout_width="wrap_content" android:layout_height="wrap_content" ></ToggleButton></LinearLayout>
activity使用
public class CreateUi extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.baseui); CheckBox che = (CheckBox)findViewById(R.id.check1); che.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubif(((CheckBox)v).isChecked())Toast.makeText(getBaseContext(), " was clicked", Toast.LENGTH_LONG).show(); else Toast.makeText(getBaseContext(), " was not clicked", Toast.LENGTH_LONG).show(); }}); RadioGroup rg = (RadioGroup)findViewById(R.id.grou1); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {// TODO Auto-generated method stubRadioButton radio = (RadioButton)findViewById(R.id.radio1);if(checkedId==radio.getId()){Toast.makeText(getBaseContext(), " option1 was clicked", Toast.LENGTH_LONG).show(); }}}); ToggleButton toggle = (ToggleButton)findViewById(R.id.toggole1); toggle.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubif(((ToggleButton)v).isChecked()){Toast.makeText(getBaseContext(), " toggle1 was clicked", Toast.LENGTH_LONG).show(); }else {Toast.makeText(getBaseContext(), ((ToggleButton)v).getText()+ " toggle1 was clicked", Toast.LENGTH_LONG).show(); }}}); } }
- android整合--UI基本控件Button,ImageButton,EditText,ChcekBox,ToggleButton,RadioButton
- 【Android 开发教程】Button,ImageButton,EditText,ChcekBox,ToggleButton,RadioButton
- Button、ImageButton、EditText、CheckBox、ToggleButton、RadioButton和Radio
- 02 - 基本控件:按钮控件(Button、ImageButton、ToggleButton)
- Android 按钮类控件大集锦:Button ToggleButton CheckBox RadioButton
- Android基本控件之Button和ImageButton
- Android基本控件 - Button和ImageButton
- android中Button,ImageButton和ToggleButton
- Android控件——TextView、EditText、ImageView、Button、ImageButton
- Android 基本UI(二)—Button、ImageButton
- Android学习-常见的UI控件 Button和ImageButton
- Android学习笔记---第四天---基础UI组件---RadioButton&CheckBox&ToggleButton&Switch---Button的子类
- Button,ImageButton,EditText三控件的应用。
- Android第四讲——常用的基本控件(一)TextView、EditText、Button、RadioButton、CheckButton、ImageView
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock
- Android - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock 的简单介绍
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock
- Android UI, TextView, Button, ToggleButton, RadioGroup
- 统计数字问题算法
- 如何把FLAC+CUE刻录成CD
- 解决VC++6.0启动_【打开文件】_对话框时出现的“0x5003eaed”问题!!!
- ==与equals方法
- html 日记本
- android整合--UI基本控件Button,ImageButton,EditText,ChcekBox,ToggleButton,RadioButton
- 彻底理解指针第三篇
- linux常用内容总结(一)
- 20130919
- Spring AOP 基本方式(Advice方式)
- 大文本文件阅读器设计
- hadoop集群datanode冲突异常
- 样式与主题
- 高性能网站设计