发布时间:2012-2-13
作者:Scalpel
分类:Program·程序
随着Android软件越做越大,我们需要把一些数据的配置信息和个性化的配置保存在手机上。那我们该怎么办?
下面我们就来看看 SharedPreferences 吧!
/* 设置保存内容 */
SharedPreferences cityInfo = getSharedPreferences("city_info", 0);
cityInfo.edit().putString("cid", "1").commit();
/* 取值 */
SharedPreferences userInfo = getSharedPreferences("city_info", 0);
String cityid = userInfo.getString("cid", "");
简单吧…… 两步就搞定了,赶快试试!
发布时间:2012-1-16
作者:Scalpel
分类:Program·程序
因为工作的需要要使用Ubuntu,只好放弃几乎完美的 Windows7。作为一个Liunx的新手,刚刚在Ubuntu终于把XMAPP给安装上了。
在安装XMAPP的时候,出现了不能解压的情况。找了N多资料发现好像是权限不够,要su来安装的。俺也不知道什么意思,反正能安装了以后再慢慢的研究!
下面开始切换:
#su命令是在用户间切换,可以是从普通用户切换到root用户,也可以是从root用户切换到普通用户。
#允许 su 到 root 设置过程如下:
test@test-desktop:~$ sudo passwd
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
test@test-desktop:~$ su
密码:
root@test-desktop:/home/test#
#当想重新从root用户回到普通用户,则使用命令su - ***
root@test-desktop:/home/test#su - test
test@test-desktop:~$
发布时间:2012-1-10
作者:Scalpel
分类:Program·程序
在做项目的时候碰到一个问题,就是当那个Activity传值给TabHost这个Activity的时候,TabHost如何把参数复制给TabHost所对应的Activity。
找了将近一个小时,终于找到问题的答案了。在这里记录一下,也给需要的朋友们!
Bundle bundle = getIntent().getExtras();
int aid = bundle.getInt("aid");
/** 这里是关键点 */
Intent contentIntent = new Intent(this,ShopContentActivity.class);
contentIntent.putExtra("aid", aid);
LayoutInflater.from(this).inflate(R.layout.shop_tab, tabHost.getTabContentView(), true);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("",
getResources().getDrawable(R.drawable.shop_home)).setContent(contentIntent));
setContentView(tabHost);
- 1