package com.xxxx.xxxx.activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.EditTextPreference;
import android.util.Log;
import android.widget.Toast;
import com.xxxx.xxxx.R;
/**
*
* 个人设置
*
*/
public class PreferenceActivity extends android.preference.PreferenceActivity implements OnPreferenceChangeListener
{
private static final String TAG = "PreferenceActivity";
private Context mCtx;
private SharedPreferences mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
mCtx = this;
mPreferences = PreferenceManager.getDefaultSharedPreferences(mCtx);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
{
preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key=preference.getKey();
if(key.equals("editkey")){
//动态改变summary的值
if(((String) newValue).trim().equals(""))
preference.setSummary(R.string.xxxx);
else
preference.setSummary(getResources().getString(R.string.xxxx)+newValue);
}else if(key.equals("listkey")){
preference.setSummary(getResources().getString(R.string.xxxx)+newValue);
}
return true;
}
});
return true;
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net