前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >8-15 Android 学习ing

8-15 Android 学习ing

作者头像
发布2018-09-03 15:35:36
4190
发布2018-09-03 15:35:36
举报
文章被收录于专栏:WD学习记录

1.match_parent

过去只有FILL_PARENT和WRAP_CONTENT那么match_parent到底是什么类型呢? 其实从Android 2.2开始FILL_PARENT改名为MATCH_PARENT ,从API Level为8开始我们可以直接用MATCH_PARENT来代替FILL_PARENT,最后Android123提醒大家,他们的定义本质是一样均为-1,只是换了个别名,可能为了更准确些,比如最终在SDK中的定义为:

fill_parent   -1  The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by match_parent.  match_parent   -1 The view should be as big as its parent (minus padding). Introduced in API Level 8.  wrap_content   -2  The view should be only big enough to enclose its content (plus padding). 

2.Android积累之《Wrong orientation? No orientation specified, and the default is horizontal, yet this la:》

Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width="match_parent"

解决方法:

在android:text="就不"时上面老是报错那个错误,是由于你的一行代码还没有加入到<LinearLayout>那个标签中的,只需加上这一行代码即可解决这个难题

  android:orientation="horizontal"

有人会问当用了android:orientation="horizontal"运行之后界面只显示一个<Textview>而自己写了4个<Textview>这是因为它的属性是为垂直线性布局的,所以只有一个显示。

解决办法:

改为下面的布局

android:orientation = "vertical"

3.私有操作模式

创建出来的文件只能被本应用访问,其他应用无法访问该文件,另外采用私有操作模式创建的文件,写入文件中的内容会覆盖原文件的内容

4.openFileOutout()

这个方法的第一参数用于指定文件名称,不能包含路径分隔符“/”,如果文件不存在,android会自动创建它,创建的文件保存在/data/data/<package name>/files目录下

5.操作模式

Context.MODE_PRIVATE:默认操作模式,代表该文件时私有数据,只能被应用本身访问,在该模式下,写入的内容会覆盖原文件的内容,如果想把新写入的内容追加到原文件中,可以使用Context.MODE_APPEND

Context.MODE_APPEND:模式会检查文件是否存在,存在就往文件中追加内容,否则创建新文件

MODE_WORLD_READABLE:表示当前文件可以被其他应用读取

MODE_WORLD_WRITEABLE:表示当前文件可以被其他应用写入

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014年08月15日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档