当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceActivity类代码示例

本文整理汇总了Java中android.preference.PreferenceActivity的典型用法代码示例。如果您正苦于以下问题:Java PreferenceActivity类的具体用法?Java PreferenceActivity怎么用?Java PreferenceActivity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PreferenceActivity类属于android.preference包,在下文中一共展示了PreferenceActivity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateDialogView

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
   protected View onCreateDialogView() {
// Get current value from preferences
mCurrentValue = getPersistedInt(mDefaultValue);

// Inflate layout
LayoutInflater inflater = ((PreferenceActivity) context).getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_slider, null);

// Setup minimum and maximum text labels
((TextView) view.findViewById(R.id.min_value)).setText(Integer.toString(mMinValue));
((TextView) view.findViewById(R.id.max_value)).setText(Integer.toString(mMaxValue));

// Setup SeekBar
mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setProgress(mCurrentValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);

// Setup text label for current value
mValueText = (TextView) view.findViewById(R.id.current_value);
mValueText.setText(Integer.toString(mCurrentValue));

return view;
   }
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:26,代码来源:SeekBarPreference.java

示例2: onOptionsItemSelected

import android.preference.PreferenceActivity; //导入依赖的package包/类
/**
 * Handle options menu
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	int id = item.getItemId();

	if (id == android.R.id.home) {
		// Do the same thing as the back button.
		onBackPressed();
		return true;
	} else if (id == R.id.action_settings) {
		Intent intent = new Intent(this, SettingsActivity.class);
		intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.SlideshowPreferenceFragment.class.getName());
		intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
		startActivity(intent);
		return true;
	} else if (id == R.id.action_credits) {
		startActivity(new Intent(this, CreditsActivity.class));
		return true;
	}
	return super.onOptionsItemSelected(item);
}
 
开发者ID:ScreamingHawk,项目名称:android-slideshow,代码行数:24,代码来源:BaseActivity.java

示例3: onResume

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
    protected void onResume() {
        super.onResume();
        SharedPreferences sharedPreferences = getSharedPreferences("USERPASS", PreferenceActivity.MODE_PRIVATE);
//        System.out.println("name is " + sharedPreferences.getString("username", "whoami"));
//        System.out.println("password is " + sharedPreferences.getString("password", "password"));

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (details != null) {
            details.clearList();
        }

        details = fragmentFactory.createRecordListFragment(tabPosition2Enum(tabPosition));

        fragmentTransaction.replace(R.id.list_fragment, details);
        fragmentTransaction.commit();
    }
 
开发者ID:shenyanf,项目名称:AccountBook,代码行数:18,代码来源:MainActivity.java

示例4: onOptionsItemSelected

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.ui_prefs :
      startActivity(new Intent(this, LaunchActivity.class).putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsFrag.class.getName()));
      return true;
    case R.id.mnu_delete :
      new AlertDialog.Builder(this)
        .setTitle(R.string.qs_delete)
        .setMessage(R.string.qs_delete_msg)
        .setNegativeButton(R.string.act_cancel, null)
        .setPositiveButton(R.string.act_delete, new DialogInterface.OnClickListener() {
          
          @Override
          public void onClick(DialogInterface dialog, int which) {
            deleteTile();
          }
        }).show();
      return true;
    default :
      return super.onOptionsItemSelected(item);
  }
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:24,代码来源:TileConfigActivity.java

示例5: onListItemClick

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
  String db = mFolderList.get(position);
  if (getActivity() instanceof PreferenceActivity) {
    Bundle extra = new Bundle();
    extra.putString("id", db);
    ((PreferenceActivity) getActivity()).startPreferencePanel(
            CFolderFrag.class.getName(),
            extra,
            R.string.lbl_customize,
            "",
            null,
            0);
  } else if (getActivity() instanceof FolderPick) {
    ((FolderPick) getActivity()).returnFolder(db, mAdapter.getItem(position));
  }
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:18,代码来源:FolderFrag.java

示例6: onCreate

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
	@SuppressWarnings("deprecation")
	@SuppressLint("WorldReadableFiles")
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
		getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
		addPreferencesFromResource(R.xml.pref_general);
//		findPreference(Common.KEY_KEYBOARD_MODE).setOnPreferenceClickListener(this);
//		findPreference(Common.KEY_RESTART_SYSTEMUI).setOnPreferenceClickListener(this);
//		findPreference(Common.KEY_STATUSBAR_TASKBAR_RESTART_SYSTEMUI).setOnPreferenceClickListener(this);
//		findPreference(Common.KEY_BLACKLIST_APPS).setOnPreferenceClickListener(this);
//		findPreference(Common.KEY_WHITELIST_APPS).setOnPreferenceClickListener(this);
//		findPreference(Common.KEY_STATUSBAR_TASKBAR_PINNED_APPS).setOnPreferenceClickListener(this);
//		if (Build.VERSION.SDK_INT >= 20) { // Lollipop
//			Preference p = findPreference("system_notif_top");
//			p.setEnabled(false);
//			p.setSummary(R.string.pref_systemui_top_summary_not_supported_lollipop);
//		}
		mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
				PreferenceActivity.MODE_WORLD_READABLE);
	}
 
开发者ID:shooash,项目名称:XHFW3,代码行数:23,代码来源:MainFragment.java

示例7: onCreate

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
	@SuppressWarnings("deprecation")
	@SuppressLint("WorldReadableFiles")
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
		getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
		addPreferencesFromResource(R.xml.pref_moving);
//		findPreference(Common.KEY_MOVABLE_WINDOW + "_titlebar_screen").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
//				@Override
//				public boolean onPreferenceClick(Preference preference) {
//					getActivity().startActivity(new Intent(getActivity(), TitleBarSettingsActivity.class));
//					return false;
//				}
//			});
		mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
												   PreferenceActivity.MODE_WORLD_READABLE);
	}
 
开发者ID:shooash,项目名称:XHFW3,代码行数:19,代码来源:MovingFragment.java

示例8: onPostExecute

import android.preference.PreferenceActivity; //导入依赖的package包/类
@Override
protected void onPostExecute(final Boolean success)

{
    if (success) {
        String formatStr = activity.getString(R.string.imported_success);

        Toast.makeText(activity,
                String.format(formatStr, totNodes, tottyp), Toast.LENGTH_SHORT).show();
        final Intent preferencesActivity = new Intent(activity, PreferencesActivity.class);

        preferencesActivity.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, DbSettingsFragment.class.getName());
        // preferencesActivity.putExtra
        // (PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS,com);
        preferencesActivity.setAction("db_setup");
        preferencesActivity.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        preferencesActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        activity.startActivity(preferencesActivity);

    } else {
        Toast.makeText(SoulissApp.getAppContext(), "Import failed", Toast.LENGTH_SHORT).show();
    }

}
 
开发者ID:souliss,项目名称:soulissapp,代码行数:26,代码来源:ImportDatabaseCSVTask.java

示例9: createGestureListPreference

import android.preference.PreferenceActivity; //导入依赖的package包/类
private static Preference createGestureListPreference(final PreferenceActivity context) {
	Preference pref = new Preference(context);
	String name = context.getString(R.string.gesture_list_str);
	pref.setKey(name);
	pref.setTitle(name);
	pref.setDefaultValue(context.getString(R.string.gesture_list_description_str));
	pref.setEnabled(true);
	pref.setSummary(context.getString(R.string.gesture_list_description_str));
	pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

		public boolean onPreferenceClick(Preference preference) {
			Intent intent = new Intent(context, tkj.android.homecontrol.mythmote.GestureBuilderActivity.class);
			context.startActivity(intent);
			return true;
		}
	});
	return pref;
}
 
开发者ID:pot8oe,项目名称:mythmote,代码行数:19,代码来源:MythMotePreferences.java

示例10: tapPreference

import android.preference.PreferenceActivity; //导入依赖的package包/类
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:27,代码来源:TestUtilities.java

示例11: createSerivceNf

import android.preference.PreferenceActivity; //导入依赖的package包/类
static Notification createSerivceNf(Context ctx) {
    @SuppressLint("InlinedApi")
    final Intent resultIntent = new Intent(ctx, MainActivity.class)
            .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "net.sf.aria2.MainActivity$Aria2Preferences")
            .putExtra(Config.EXTRA_FROM_NF, true);

    // note: using addParentStack results in hanging for some reason (confirmed on JellyBean)
    // there is only one activity in stack to handle up and back navigation differently
    final TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx)
            .addNextIntent(resultIntent);
    final PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    return new NotificationCompat.Builder(ctx)
            .setSmallIcon(R.drawable.ic_nf_icon)
            .setTicker("aria2 is running")
            .setContentTitle("aria2 is running")
            .setContentText("Touch to open settings")
            .setContentIntent(contentIntent)
            .setOnlyAlertOnce(true)
            .build();
}
 
开发者ID:chdir,项目名称:aria2-android,代码行数:22,代码来源:NfBuilder.java

示例12: updateTitle

import android.preference.PreferenceActivity; //导入依赖的package包/类
private void updateTitle() {
    final String newTitle = getTitle();
    if (newTitle == null) {
        Log.d(LOGTAG, "No new title to show.");
        return;
    }

    final PreferenceActivity activity = (PreferenceActivity) getActivity();
    if (Versions.feature11Plus && activity.isMultiPane()) {
        // In a multi-pane activity, the title is "Settings", and the action
        // bar is along the top of the screen. We don't want to change those.
        activity.showBreadCrumbs(newTitle, newTitle);
        return;
    }

    Log.v(LOGTAG, "Setting activity title to " + newTitle);
    activity.setTitle(newTitle);

    if (Versions.feature14Plus) {
        final ActionBar actionBar = activity.getActionBar();
        if (actionBar != null) {
            actionBar.setTitle(newTitle);
        }
    }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:26,代码来源:GeckoPreferenceFragment.java

示例13: getResource

import android.preference.PreferenceActivity; //导入依赖的package包/类
private int getResource() {
    int resid = 0;

    final String resourceName = getArguments().getString("resource");
    final Activity activity = getActivity();

    if (resourceName != null) {
        // Fetch resource id by resource name.
        final Resources resources = activity.getResources();
        final String packageName = activity.getPackageName();
        resid = resources.getIdentifier(resourceName, "xml", packageName);
    }

    if (resid == 0) {
        // The resource was invalid. Use the default resource.
        Log.e(LOGTAG, "Failed to find resource: " + resourceName + ". Displaying default settings.");

        boolean isMultiPane = Versions.feature11Plus &&
                              ((PreferenceActivity) activity).isMultiPane();
        resid = isMultiPane ? R.xml.preferences_customize_tablet : R.xml.preferences;
    }

    return resid;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:25,代码来源:GeckoPreferenceFragment.java

示例14: setupTopLevelFragmentIntent

import android.preference.PreferenceActivity; //导入依赖的package包/类
/**
 * Set intent to display top-level settings fragment,
 * and show the correct title.
 */
private void setupTopLevelFragmentIntent() {
    Intent intent = getIntent();
    // Check intent to determine settings screen to display.
    Bundle intentExtras = intent.getExtras();
    Bundle fragmentArgs = new Bundle();
    // Add resource argument to fragment if it exists.
    if (intentExtras != null && intentExtras.containsKey(INTENT_EXTRA_RESOURCES)) {
        String resourceName = intentExtras.getString(INTENT_EXTRA_RESOURCES);
        fragmentArgs.putString(INTENT_EXTRA_RESOURCES, resourceName);
    } else {
        // Use top-level settings screen.
        if (!onIsMultiPane()) {
            fragmentArgs.putString(INTENT_EXTRA_RESOURCES, "preferences");
        } else {
            fragmentArgs.putString(INTENT_EXTRA_RESOURCES, "preferences_customize_tablet");
        }
    }

    // Build fragment intent.
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, GeckoPreferenceFragment.class.getName());
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:27,代码来源:GeckoPreferences.java

示例15: setResourceToOpen

import android.preference.PreferenceActivity; //导入依赖的package包/类
/**
 * Given an Intent instance, add extras to specify which settings section to
 * open.
 *
 * resource should be a valid Android XML resource identifier.
 *
 * The mechanism to open a section differs based on Android version.
 */
public static void setResourceToOpen(final Intent intent, final String resource) {
    if (intent == null) {
        throw new IllegalArgumentException("intent must not be null");
    }
    if (resource == null) {
        return;
    }

    if (Versions.preHC) {
        intent.putExtra("resource", resource);
    } else {
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, GeckoPreferenceFragment.class.getName());

        Bundle fragmentArgs = new Bundle();
        fragmentArgs.putString("resource", resource);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
    }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:27,代码来源:GeckoPreferences.java


注:本文中的android.preference.PreferenceActivity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。