重温5 UI开发
来源:互联网 发布:淘宝怎么搜有图评价 编辑:程序博客网 时间:2024/05/11 18:13
public class
TextView
extends View
implements ViewTreeObserver.OnPreDrawListenerjava.lang.Object ↳android.view.View ↳android.widget.TextViewKnown Direct SubclassesKnown Indirect Subclasses1、fill_parent与match_parent
Button,CheckedTextView,Chronometer,DigitalClock,EditText,TextClock
ButtonRepresents a push-button widget. CheckedTextViewAn extension to TextView that supports the
Checkable
interface. ChronometerClass that implements a simple timer. DigitalClockThis class was deprecated in API level 17. It is recommended you useTextClock
instead. EditTextEditText is a thin veneer over TextView that configures itself to be editable. TextClockTextClock
can display the current date and/or time as a formatted string.
AutoCompleteTextView,CheckBox,CompoundButton,ExtractEditText,MultiAutoCompleteTextView,RadioButton,Switch,ToggleButton
Android2.2开始两者相同,2.2之前用fill_parent,官方推荐match_parent。
2、layout_gravity与gravity
2.1)gravity:指定控件中文字的对齐方式。
layout_gravity:指定控件在所在布局中的对齐方式。
LinearLayout中:
orientation:vertical时:layout_gravity水平方向的设置有效:left/right/center_horizontal
orientation:horiaontal时:layout_gravity垂直方向设置有效:top/bottom/center_vertical. center 都可以用,总有一个方向生效
2.2)想要设置某个控件居底,可以在空间外加一层LinearLayout并设置其gravity为bottom.
<LinearLayout...android:gravity="bottom"...> <Button....../></LinearLayout>3、Button点击事件
3.1)XML:
<Button...android:onClick="onClick"/><!--点击事件的方法名-->
public void onClick(View view){}3.2)
login_btn.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View view){}}});//匿名类的方式3.3)
public class MainActivity extends Activity implements onClickListener{ @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Button button = (Button)findViewById(R.id.button); button.setOnClickListener(this);} @Override public void onClick(View view){}}
3.4)
Button Btn = (Button) findViewById(R.id.button); Btn2.setOnClickListener(listener);//设置监听 } Button.OnClickListener listener = new Button.OnClickListener(){//创建监听对象 public void onClick(View v){ } };4、EditText
当需要输入EditText中的内容过多时,可以指定最大行数,当达到最大行数时文本就会往上滚动。
android:maxLines="2"5、ProgressBar/AlertDialog/ProgressDialog
<ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" /><!-- 可以设置style="?android:attr/progressBarStyleHorizontal" android:max="100"-->
//AlertDialog/ProgressDialog
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();switch(id){case R.id.alertDialog: AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Warning"); alertDialog.setMessage("This is a warning"); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}}); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}}); alertDialog.show(); break;case R.id.progressDialog:ProgressDialog progressDialog = new ProgressDialog(this);progressDialog.setTitle("ProgressDialog");progressDialog.setMessage("loading...");progressDialog.show();break;default:}return super.onOptionsItemSelected(item);}
完整代码在:https://github.com/HiSunny/ComeOnProgressBarAlertDialogProgressDialog.git
0 0
- 重温5 UI开发
- 重温
- Android 技术重温系列 (10)- UI 组件
- 重温eclipse---配置jsp开发环境
- 重温Web开发及技术选型
- SQL教程重温(5)
- Android 技术重温系列 ( 5 )
- 重温python基础5:引用
- UI开发
- UI开发
- UI 开发
- UI 开发
- Tizen 开发(5) - UI Application Fundamentals
- 5大顶级移动UI开发框架
- 开发一个小工具重温C#经典问题
- iPhone UI开发建议
- wince UI 开发
- iphone UI 开发教程
- hiho-102周 搜索五·数独
- 6-2CSS样式的优势
- 自定义滚动条
- Linux 系统中的硬链接与软链接
- startActivityForResult用法详解
- 重温5 UI开发
- JAVA中实现线程相互调用或回调
- LOOP,LEAVE 语句
- Mybatis批量插入oracle
- Spring AOP切面实现:示例
- CodeForces 679B(Bear and Tower of Cubes)
- 【一天一道LeetCode】#96. Unique Binary Search Trees
- 6-3CSS代码语法
- 乒乓球DOM小游戏