android开发错误经验总结
2024-09-05 19:07:47
TextView:
1.textView.setText();参数如果直接传int类型,ide不会显示错误。但是运行会报错。
布局渲染:
1.
<View
android:background="#E5E5E5"
android:layout_width="match_parent"
android:layout_height="1dp"/>
划一条横线的时候记得View要大写。否则报错。 2.在studio中定义drawable资源及获取方法:
<string-array name="actions_images">
<item>@drawable/pencil1</item>
<item>@drawable/pencil2</item>
<item>@drawable/pencil3</item>
<item>@drawable/pencil4</item>
<item>@drawable/pencil5</item>
<item>@drawable/pencil6</item>
</string-array>
获取方法:
TypedArray ar = context.getResources().obtainTypedArray(R.array.actions_images);
int len = ar.length();
int[] resIds = new int[len];
for (int i = 0; i < len; i++)
resIds[i] = ar.getResourceId(i, 0); ar.recycle();
不能够定义为Integer。这样获取不到。
最新文章
- Device.js – 快速检测平台、操作系统和方向信息
- SqlSever基础 rtrim函数 除去字符串的右边的空格,左边中间的不管
- linux初学 :linux 常用命令(一)
- android Button 切换背景,实现动态按钮和按钮颜色渐变
- 【转载】svn代码回滚命令
- .net的 async 和 await
- 类linux系统/proc/sysrq-trigger文件功能作用
- 网络资源(7) - JAX-WS视频
- oracle存储过程+游标处理select数据
- 字符串匹配&mdash;KMP 扩展KMP Manacher
- js 获取上传视频的时长、大小、后缀名
- POI操作excle
- python作业练习
- shell脚本学习-循环
- Java JDK与JRE
- MySQL触发器trigger的使用
- Misunderstood-Missing-逆向DP
- php三级联动(html,php两个页面)
- 定时器QTimer
- what&#39;s the python之变量、基本数据类型