Android25图灵聊天项目------在代码中拿到资源文件string.xml中的数据
2015-06-06 17:39
513 查看
string.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">25图灵聊天</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="send">发送</string>
<string-array name="welcome_tips">
<item>主人,奴婢在此等候多时了</item>
<item>主人,近来一切可好</item>
<item>亲爱的,我想死你了</item>
<item>欢迎归来,我亲爱的主人</item>
<item>我是图灵机器人,很高兴为您服务</item>
</string-array>
</resources>
/**
* 拿到string.xml中的数据,放到数组,随机取出
*
*
*/
private String getRandomWelcomeTips() {
String welcome_tip = null;
private String[] welcome_array = this.getResources().getStringArray(R.array.welcome_tips);
int index = (int) (Math.random() * (welcome_array.length - 1));
welcome_tip = welcome_array[index];
return welcome_tip;
}
相关文章推荐
- android之ListView使用
- android 按钮切换activity和打开网页
- Android Fragment嵌套使用问题总结
- Android 在锁屏界面添加未读短信和电话提醒
- Android的开发学习
- Android常用工具类
- Android实现首次点击返回键提示信息,第二次点击退出应用
- Android Native/Tombstone Crash Log 详细分析
- 在Android中探秘建造者模式
- Android 广播的生命周期
- Android系统中的广播(Broadcast)机制简要介绍和学习计划
- 【转】Android 平台下使用 i2c-tools
- Android中Bitmap和Drawable
- 关于Fragment API版本兼容问题
- 1第一个Android应用程序
- android百度地图定位,点击给定经纬度的某点进行弹窗
- androidstudio中出现Rendering Problems,字体太小,显示不了组件问题
- 安卓showTime and showDate 两个按钮,并在xml中写入相应的onClick方法
- Android之NDK开发
- Android 部分属性学习