Android, 基本控件的使用
来源:互联网 发布:妩媚的女生 知乎 编辑:程序博客网 时间:2024/05/19 06:49
1. <TextView 用于在界面上显示一段文字。。
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="24sp"
android:textColor="#00ff00"
android:text="This is TextView" />
2.<Button 设置一个按钮。。。
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"/>
3.<EditText 允许用户在控件里输入和编辑内容。。。
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type something here"
android:maxLines="2"
/>
4.<ImageView 用于在界面上展示图片的一个控件。。。
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
5.<ProgressBar 用于在界面上显示一个进度条,表明我们的程序正在加载。。
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
/>
6.AlertDialog可以在当前窗口弹出一个对话框,这个对话框是置顶于所有界面元素之上的,能够屏蔽掉其他控件的交互能力,一般用于提示一些非常重要的内容或者警告内容。。。
public void onClick(View v){
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("This is a Dialog");dialog.setMessage("Something important.");
dialog.setCancelable(false);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
dialog.show();
7.ProgressDialog与AlertDialog类似,但会在对话框中显示一个进度条。。
public void onClick(View v){
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("This is ProgressDialog");
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("This is ProgressDialog");
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();
0 0
- Android, 基本控件的使用
- android基本控件的使用
- Android基本控件的使用
- 【Android】Android常用控件的基本使用
- Android基本控件使用
- android最基本的控件使用
- Android中WebView控件的基本使用
- <Android>控件Spinner的基本使用
- android基本类型的自定义控件使用
- Android基本控件ListView的使用总结
- Android基本控件之Spinner的使用
- Android控件之RecyclerView的基本使用
- Android 控件 RecyclerView 的基本使用
- Android基本控件的使用(1)
- Android基本控件的使用(2)
- Android基本控件的使用(3)
- Android 控件DrawerLayout的基本使用
- Android-控件WebView的基本使用
- linux查看系统负载
- 黑马程序员android 应用程序资源 以及访问
- Spring MVC中使用@Autowired实现自动注入
- C# 编写Windows Service(windows服务程序)
- phpMyAdmin Linux 安装 配置
- Android, 基本控件的使用
- 不容错过!开发者必备的十二大Android开发资源
- P3-weixin-2.0.0版本发布(微信插件式开发框架)
- 移动端字体排版设计准则
- Spring 自动扫描组件
- 一个技术博客,关于PE_C++_驱动_病毒
- PHP MysqlI操作数据库
- Android:clipChildren属性
- java对List的分页操作