涉及的知识点:
1.TextView标签的使用;
2.drawable定义颜色常数的方法
3.引用drawable颜色常数及背景色
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="30sp"
android:background="@drawable/red"
android:gravity="center_vertical|center_horizontal"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/appearance"
android:textSize="20sp"
android:textColor="@drawable/Black"
android:gravity="center_vertical|center_horizontal"
android:background="@drawable/yellow"
/>
4.Button按钮事件处理
button.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
/*写入点击button要达到的目的*/
}
}
);
5.Intent对象的使用
Intent intent = new Intent();
intent.setClass(SPoof.this,SPoof_1.class);
Bundle bundle = new Bundle();
bundle.putDouble("rp",rp);
bundle.putDouble("zx",zx);
intent.putExtras(bundle);
startActivity(intent);

6.不同Activity之间的数据传递--Bundle对象的实现
Bundle bunde = this.getIntent().getExtras();
double zx = bunde.getDouble("zx");
double rp = bunde.getDouble("rp");

7.AlerDialig窗口的使用
new AlertDialog.Builder(SPoof_1.this)
.setTitle("提示")
.setMessage("请输入0-100数字")
.setPositiveButton(R.string.str_ok,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialoginterface, int i)
{
/*写入点击button要达到的目的*/
}
}
)
.show();

本例中,在第一个activity里输入数据,点击按钮,将数据传递至另外一个activity,并根据
输入的内容输出相应信息,若输入不为0-100,会给出提示.

调试过程中,我遇到过的问题:
1.程式不报错,但是运行会弹出错误对话框
解决:
例子中使用了两个activity所以必须在AndroidManifest.xml中增加下列信息
<activity android:name="SPoof_1"></activity>.

2.bundle put对象时出错

解决:

定义要put的对象应和bundle处于同一层,我在外层使用fanal关键字定义,虽运行不报错,但数据仍然不能传送。

3.TextView显示的内容与button按钮在视觉上重合。

解决:

在LinearLayout 时,需定义好android:layout_width和android:layout_height,一般是fill_parent或者wrap_content
思考拓展:

本例只使用了两个界面,还可在后续界面上加上button跳转到其它界面,如七彩变幻,计算器,图片浏览等。

v的旋律

2011-04-18

Android入门学习笔记之人机用户界面2

本例实现一个登陆进入自定义的图片滑动浏览界面:

涉及的知识点:
1.EditView中显示默认文字(请输入帐号名:请输入密码)
2.打勾显示让输入的密码可见
3.AlertDialog中添加图片
4.Menu功能菜单设计
5.和上例一样设计到intent的使用---跳转Activity
6.gallery的简单使用
7.图像的取得,读取,成像

遇到过的问题:
1.同上次一样,两个activity,我又忘了在AndroidManifest.xml中声明activity了.结果是程序不报错,但运行会crash.
2.如何判断帐号名和密码?
解决:开始把密码转换为double型,但是这造成的结果是程序运行输入不是数字的话,程序就会出错,所以应该采用字符串来判定,字符串的判定使用equals().而不是"==".
3.Menu.add()中三个参数的作用?
解决:
参考的资料
第一个int类型的group ID参数,代表的是组概念,你可以将几个菜单项归为一组,以便更好的以组的方式管理你的菜单按钮。
第二个int类型的item ID参数,代表的是项目编号。这个参数非常重要,一个item ID对应一个Menu中的选项。在后面使用菜单的时候,就是靠这个item ID来判断,你选中的是哪个选项。
第三个int类型的order ID参数,代表的是菜单项的显示顺序。默认是0,表示菜单的显示顺序就是按照add的顺序来显示。

更多相关文章

  1. 箭头函数的基础使用
  2. NPM 和webpack 的基础使用
  3. Python list sort方法的具体使用
  4. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  5. 一个Demo让你掌握所有的android控件
  6. gson使用在android使用例子
  7. ImageView的scaletype属性
  8. Ubuntu上安装和使用Android(安卓)Studio
  9. Android(安卓)网络显示图片

随机推荐

  1. Android(安卓)文件实现断点上传
  2. android 对话框全屏
  3. adt-bundle-windows-x86_32-20140702
  4. Android(安卓)Webview播放HTML5 video的
  5. 使Android原生时间选择器样式为滚轮
  6. Android(安卓)分享功能
  7. android 随笔提示
  8. 2014.04.21 ——— android 魅族SmartBar
  9. 使用Android(安卓)Studio时报错 Manifest
  10. Android(安卓)java.lang.IllegalArgument