Compiz Fusion 安装后的设置
2007-09-10 09:20
155 查看
以复选和单选框为列:
在回退之前,保存选项。
1、数据保存在File Explorer --> data -->data -->[
该项目的包](项目在虚拟机上运行之后,操作完毕返回
后,该项目的包内会自动生成文件)
xml文件
<CheckBox
android:id="@+id/cb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="背景音乐"/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rb3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3格"/>
<RadioButton
android:id="@+id/rb6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="6格"/>
<RadioButton
android:id="@+id/rb9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="9格"/>
</RadioGroup>
java代码
public class ProjActivity extends Activity{
private CheckBox cb1;
private RadioButton rb1;
private RadioButton rb2;
private RadioButton rb3;
@Override
public void onCreate(Bundle
savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onStart(){
super.onStart();
cb1 = (CheckBox)findViewById
(R.id.cb1);
rb1 = (RadioButton)findViewById
(R.id.rb3);
rb2 = (RadioButton)findViewById
(R.id.rb6);
rb3 = (RadilButton)findViewById
(R.id.rb9);
//获取选项数据存储
SharedPreferences sp =
getSharedPreferences
("setting",Context.MODE_PRIVATE);
boolean music = sp.getBoolean
("music",true);
cb1.setChecked(music);
int grids = sp.getInt("grids",3);
if(grids == 3)
rb1.setChecked(true);
else if(grids == 6)
rb2.setChecked(true);
else
rb3.setChecked(true);
}
@Override
protected void onStop(){
super.onStop();
//获取选项数据存储
SharedPreferences sp =
getSharedPreferences
("setting",Context.MODE_PRIVATE);
//获取选项数据存储编辑器
Editor editor = sp.edit();
editor.putBoolean
("music",cb1.isChecker());
if(rb1.isChecked()){
editor.putInt("grids",3);
}
if(rb2.isChecked()){
editor.putInt("grids",6);
}
if(rb3.isChecked()){
editor.putInt("grids",9);
}
//提交数据
editor.commit();
}
}
本文出自 “android存储数据” 博客,请务必保留此出处http://20111228.blog.51cto.com/4145777/752860
在回退之前,保存选项。
1、数据保存在File Explorer --> data -->data -->[
该项目的包](项目在虚拟机上运行之后,操作完毕返回
后,该项目的包内会自动生成文件)
xml文件
<CheckBox
android:id="@+id/cb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="背景音乐"/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/rb3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3格"/>
<RadioButton
android:id="@+id/rb6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="6格"/>
<RadioButton
android:id="@+id/rb9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="9格"/>
</RadioGroup>
java代码
public class ProjActivity extends Activity{
private CheckBox cb1;
private RadioButton rb1;
private RadioButton rb2;
private RadioButton rb3;
@Override
public void onCreate(Bundle
savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onStart(){
super.onStart();
cb1 = (CheckBox)findViewById
(R.id.cb1);
rb1 = (RadioButton)findViewById
(R.id.rb3);
rb2 = (RadioButton)findViewById
(R.id.rb6);
rb3 = (RadilButton)findViewById
(R.id.rb9);
//获取选项数据存储
SharedPreferences sp =
getSharedPreferences
("setting",Context.MODE_PRIVATE);
boolean music = sp.getBoolean
("music",true);
cb1.setChecked(music);
int grids = sp.getInt("grids",3);
if(grids == 3)
rb1.setChecked(true);
else if(grids == 6)
rb2.setChecked(true);
else
rb3.setChecked(true);
}
@Override
protected void onStop(){
super.onStop();
//获取选项数据存储
SharedPreferences sp =
getSharedPreferences
("setting",Context.MODE_PRIVATE);
//获取选项数据存储编辑器
Editor editor = sp.edit();
editor.putBoolean
("music",cb1.isChecker());
if(rb1.isChecked()){
editor.putInt("grids",3);
}
if(rb2.isChecked()){
editor.putInt("grids",6);
}
if(rb3.isChecked()){
editor.putInt("grids",9);
}
//提交数据
editor.commit();
}
}
本文出自 “android存储数据” 博客,请务必保留此出处http://20111228.blog.51cto.com/4145777/752860
相关文章推荐
- Compiz Fusion 安装后的设置
- 安装设置Android Studio Win7安装
- [转]Lomboz安装与设置(英文原版)
- 用虚拟机安装了红帽后,我确实没设置用户名密码,但现在一打开就让输入用户名密码。这种情况该怎么办??
- 安装office2003的时候提示(系统管理员设置了系统策略,禁止进行此安装)的解决办法
- Windows下安装并设置Redis
- 虚拟机下安装ubuntu后root密码设置
- Mysql安装及设置
- Window安装Redis并设置为开机启动
- Ubuntu安装和设置SSH服务
- Kali-linux安装之后的简单设置
- python 安装及设置默认
- Mac Pro 安装 Sublime Text 2.0.2,个性化设置,主题 和 插件 收藏
- 一个完整的Installshield安装程序实例—艾泽拉斯之海洋女神出品(二) --基本设置二
- (1)DHCP的安装与授权 (2)地址、排除地址的建立 (3)选项的设置
- 【设置字符集】Win7 64位系统安装MySQL5.5.21图解教程
- centos7 双网卡双ip内外网设置最小化安装
- IDEA第一章----下载安装idea,设置背景字体编码,配置JDK/Maven
- ANT在Mac OS X上的安装和设置
- eclipse安装android sdk后工具栏没有图标的设置