preferenceactivity,preferenceactivity 控件
在Android中,如何在PreferenceActivity上实现动画效果?
AnimationSet set = new AnimationSet(false);// 创建动画效果
Animation animation = new AlphaAnimation(0,1);
animation.setDuration(500);
set.addAnimation(animation);
animation = new TranslateAnimation(1, 13, 10, 50);
animation.setDuration(300);
set.addAnimation(animation);
animation = new RotateAnimation(30,10);
animation.setDuration(300);
set.addAnimation(animation);
animation = new ScaleAnimation(5,0,2,0);
animation.setDuration(300);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 1);
// 在GridView上使用
GridView gv = (GridView) this.findViewById(R.id.gv_apps);
gv.setLayoutAnimation(controller);
关于PreferenceActivity.怎么监听其中编辑框的确定按钮
当点确定之后,会自动执行
public boolean onPreferenceChange(Preference preference, Object
newValue) {
preference.setSummary(String.valueOf(newValue));
return
true;
}
这个方法
其中preference是标题+空格+编辑框里面的值。而newValue就是值
我直接
String
setting=preference.toString().substring(0, preference.toString().indexOf("
"));
if(setting.equals("IP设置"))
{
MyApplication.setIp(newValue.toString());
}
if(setting.equals("端口设置"))
{
MyApplication.setPort(newValue.toString());
}
if(setting.equals("邀请码"))
{
MyApplication.setBrideGroomCode(newValue.toString());
}
这样截取。判断。
就可以依次保存里面的值了。。。。

如何使用preferenceactivity创建应用程序设置的用户界面
这个应该就是一个简单的Activity吧,PreferenceActivity不能做出这个效果吧。PreferenceActivity里面就是一个ListView,你可以加header和footer,但这种效果,可能即使一个普通的activity。
android studio怎么用preferenceactivity
在每个switchpreference的onclick事件里面设置模拟点击事件不需要人为触发,View.performClick()
如何从支持库中添加动作栏为preferenceActivity
编辑:在appcompat-V7 22.1.0谷歌增加了AppCompatDelegate抽象类作为一个代表,你可以用它来AppCompat的支持扩展到任何活动
使用这样的:
...
进口android.support.v7.app.ActionBar;
进口android.support.v7.app.AppCompatDelegate;
进口android.support.v7.widget.Toolbar;
...
公共类SettingsActivity扩展preferenceActivity {
私人AppCompatDelegate mDelegate;
@覆盖
保护无效的onCreate(包savedInstanceState){
getDelegate()installViewFactory()。
getDelegate()的onCreate(savedInstanceState)。
super.onCreate(savedInstanceState);
}
@覆盖
保护无效onPostCreate(包savedInstanceState){
super.onPostCreate(savedInstanceState);
getDelegate()onPostCreate(savedInstanceState)。
}
公共动作条getSupportActionBar(){
返回getDelegate()getSupportActionBar()。
}
公共无效setSupportActionBar(@Nullable工具栏工具栏){
getDelegate()setSupportActionBar(工具栏)。
}
@覆盖
公共MenuInflater getMenuInflater(){
返回getDelegate()getMenuInflater()。
}
@覆盖
公共无效的setContentView(@LayoutRes INT layoutResID){
getDelegate()的setContentView(layoutResID)。
}
@覆盖
公共无效的setContentView(查看视图){
getDelegate()的setContentView(图)。
}
@覆盖
公共无效的setContentView(查看视图,ViewGroup.LayoutParams PARAMS){
getDelegate()的setContentView(视图,则params)。
}
@覆盖
公共无效addContentView(查看视图,ViewGroup.LayoutParams PARAMS){
。getDelegate()addContentView(视图,则params);
}
@覆盖
保护无效onPostResume(){
super.onPostResume();
getDelegate()onPostResume()。
}
@覆盖
保护无效onTitleChanged(CharSequence的标题,INT的颜色){
super.onTitleChanged(标题,彩色);
getDelegate()的setTitle(职称)。
}
@覆盖
公共无效onConfigurationChanged(配置NEWCONFIG){
super.onConfigurationChanged(NEWCONFIG);
getDelegate()onConfigurationChanged(NEWCONFIG)。
}
@覆盖
保护无效的onStop(){
super.onStop();
getDelegate()的onStop()。
}
@覆盖
保护无效的onDestroy(){
super.onDestroy();
getDelegate()的onDestroy()。
}
公共无效invalidateOptionsMenu(){
。getDelegate()invalidateOptionsMenu();
}
私人AppCompatDelegate getDelegate(){
如果(mDelegate == NULL){
mDelegate = AppCompatDelegate.create(这一点,NULL);
}
返回mDelegate;
}