android.os.Bundle.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(282)

本文整理了Java中android.os.Bundle.<init>()方法的一些代码示例,展示了Bundle.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.<init>()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:<init>

Bundle.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Intent mIntent = new Intent(this, Example.class);
Bundle mBundle = new Bundle();
mBundle.putString(key, value);
mIntent.putExtras(mBundle);

代码示例来源:origin: androidannotations/androidannotations

@Override
public Parcelable onSaveInstanceState() {
  Bundle bundle = new Bundle();
  bundle.putString("stringState", stringState);
  bundle.putParcelable("beanState", beanState);
  return bundle;
}

代码示例来源:origin: stackoverflow.com

public static MyFragment newInstance(int someInt) {
  MyFragment myFragment = new MyFragment();

  Bundle args = new Bundle();
  args.putInt("someInt", someInt);
  myFragment.setArguments(args);

  return myFragment;
}

代码示例来源:origin: stackoverflow.com

public class SecondFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View v = inflater.inflate(R.layout.second_frag, container, false);

  TextView tv = (TextView) v.findViewById(R.id.tvFragSecond);
  tv.setText(getArguments().getString("msg"));

  return v;
}

public static SecondFragment newInstance(String text) {

  SecondFragment f = new SecondFragment();
  Bundle b = new Bundle();
  b.putString("msg", text);

  f.setArguments(b);

  return f;
}
}

代码示例来源:origin: stackoverflow.com

setArguments(new Bundle());
View view = inflater.inflate(R.layout.fragment_a, null);
persistentVariableEdit = (EditText) view.findViewById(R.id.editText);
TextView proofTextView = (TextView) view.findViewById(R.id.textView);
view.findViewById(R.id.btnPushFragmentB).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

代码示例来源:origin: facebook/facebook-android-sdk

private static Bundle jsonToBundle(JSONObject jsonObject) throws JSONException {
  Bundle bundle = new Bundle();
  Iterator iter = jsonObject.keys();
  while (iter.hasNext()) {
    String key = (String) iter.next();
    String value = jsonObject.getString(key);
    bundle.putString(key,value);
  }
  return bundle;
}

代码示例来源:origin: stackoverflow.com

mListener = listener;
  ActionFragment fragment = new ActionFragment();
  Bundle args = new Bundle();
  args.putInt("ICON", iconResId);
  args.putInt("LABEL", labelResId);
  fragment.setArguments(args);
  return fragment;
  return inflater.inflate(R.layout.fragment_action, container, false);
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  vIcon = (CircledImageView) view.findViewById(R.id.icon);
  vLabel = (TextView) view.findViewById(R.id.label);
  vIcon.setImageResource(getArguments().getInt("ICON"));
  vLabel.setText(getArguments().getInt("LABEL"));

代码示例来源:origin: HotBitmapGG/bilibili-android-client

public static void launch(Activity activity, RegionTypesInfo.DataBean dataBean) {
  Intent mIntent = new Intent(activity, RegionTypeDetailsActivity.class);
  Bundle bundle = new Bundle();
  bundle.putParcelable(ConstantUtil.EXTRA_PARTITION, dataBean);
  mIntent.putExtras(bundle);
  activity.startActivity(mIntent);
}

代码示例来源:origin: stackoverflow.com

Bundle args = new Bundle();
args.putInt("someInt", someInt);
args.putString("someString", someString);
// Put any other arguments
myFragment.setArguments(args);

代码示例来源:origin: robolectric/robolectric

@Test(expected = IllegalArgumentException.class)
public void shouldValidateSyncExtrasAndThrow() {
 Bundle bundle = new Bundle();
 bundle.putParcelable("intent", new Intent());
 ContentResolver.validateSyncExtrasBundle(bundle);
}

代码示例来源:origin: stackoverflow.com

Bundle args = new Bundle();
ArrayList<String> argsValue = new ArrayList<String>(data);
args.putStringArrayList(DATA_ARGS_KEY, argsValue);
return inflater.inflate(R.layout.pager_fragment, container, false);
pagerData = (ViewPager) view.findViewById(R.id.pager_data);
setupPagerData();

代码示例来源:origin: commonsguy/cw-omnibus

private void editPrefs() {
  Intent i=new Intent(this, EditPreferences.class);

  i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
        StockPreferenceFragment.class.getName());

  Bundle b=new Bundle();

  b.putString("resource", "preferences");

  i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, b);

  startActivity(i);
 }
}

代码示例来源:origin: stackoverflow.com

public class MyFragment extends Fragment {
  @Override
  public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.frag_layout, container, false);

    boolean shouldCreateChild = getArguments().getBoolean("shouldYouCreateAChildFragment");

    if (shouldCreateChild) {
      FragmentManager fm = getFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();

      fm.beginTransaction();
      Fragment fragTwo = new MyFragment();
      Bundle arguments = new Bundle();
      arguments.putBoolean("shouldYouCreateAChildFragment", false);
      fragTwo.setArguments(arguments);
      ft.add(R.id.frag_container, fragTwo);
      ft.commit();

    }

    return layout;
  }
}

代码示例来源:origin: stackoverflow.com

StationInfoAccessibilityFragment fragment = new StationInfoAccessibilityFragment();
  final Bundle args = new Bundle(1);
  args.putString(EXTRA_CRS_CODE, crsCode);
  fragment.setArguments(args);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  mInflater = inflater;
  return inflater.inflate(R.layout.fragment_station_accessibility, container, false);

代码示例来源:origin: robolectric/robolectric

@Test
public void testBundleExtra() throws Exception {
 Intent intent = new Intent();
 Bundle bundle = new Bundle();
 bundle.putInt("bar", 5);
 assertSame(intent, intent.putExtra("foo", bundle));
 assertEquals(5, intent.getBundleExtra("foo").getInt("bar"));
}

代码示例来源:origin: facebook/facebook-android-sdk

arrayList.add("third");
Bundle innerBundle1 = new Bundle();
innerBundle1.putInt("inner", 1);
Bundle innerBundle2 = new Bundle();
innerBundle2.putString("inner", "2");
innerBundle2.putStringArray("deep list", new String[] {"7", "8"});
Bundle b = new Bundle();
b.putBoolean("boolValue", true);
b.putInt("intValue", 7);
b.putLong("longValue", 5000000000l);
b.putDouble("doubleValue", 3.14);
b.putString("stringValue", "hello world");
b.putStringArray("stringArrayValue", new String[] {"first", "second"});
b.putStringArrayList("stringArrayListValue", arrayList);
assertEquals(5000000000l, json.getLong("longValue"));
assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals("hello world", json.getString("stringValue"));
assertEquals(1, innerJson.getInt("inner"));
innerJson = innerJson.getJSONObject("nested bundle");
assertEquals("2", innerJson.getString("inner"));

代码示例来源:origin: googlesamples/easypermissions

Bundle toBundle() {
  Bundle bundle = new Bundle();
  bundle.putString(KEY_POSITIVE_BUTTON, positiveButton);
  bundle.putString(KEY_NEGATIVE_BUTTON, negativeButton);
  bundle.putString(KEY_RATIONALE_MESSAGE, rationaleMsg);
  bundle.putInt(KEY_THEME, theme);
  bundle.putInt(KEY_REQUEST_CODE, requestCode);
  bundle.putStringArray(KEY_PERMISSIONS, permissions);
  return bundle;
}

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent(first.this, second.class);

Bundle bundle = new Bundle();
bundle.putInt("index", index);

intent.putExtras(bundle);startActivity(intent);

代码示例来源:origin: stackoverflow.com

Bundle b=new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);

代码示例来源:origin: stackoverflow.com

@Override
public void onBackPressed() {
  Bundle bundle = new Bundle();
  bundle.putString(FIELD_A, mA.getText().toString());

  Intent mIntent = new Intent();
  mIntent.putExtras(bundle);
  setResult(RESULT_OK, mIntent);
  super.onBackPressed();
}

相关文章

Bundle类方法