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

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

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

Bundle.putInt介绍

暂无

代码示例

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

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
 super.onSaveInstanceState(savedInstanceState);
 // Save UI state changes to the savedInstanceState.
 // This bundle will be passed to onCreate if the process is
 // killed and restarted.
 savedInstanceState.putBoolean("MyBoolean", true);
 savedInstanceState.putDouble("myDouble", 1.9);
 savedInstanceState.putInt("MyInt", 1);
 savedInstanceState.putString("MyString", "Welcome back to Android");
 // etc.
}

代码示例来源: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

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

代码示例来源: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);

代码示例来源:origin: yipianfengye/android-zxingLibrary

@Override
public void onAnalyzeSuccess(Bitmap mBitmap, String result) {
  Intent resultIntent = new Intent();
  Bundle bundle = new Bundle();
  bundle.putInt(CodeUtils.RESULT_TYPE, CodeUtils.RESULT_SUCCESS);
  bundle.putString(CodeUtils.RESULT_STRING, result);
  resultIntent.putExtras(bundle);
  CaptureActivity.this.setResult(RESULT_OK, resultIntent);
  CaptureActivity.this.finish();
}

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

public static void launch(Activity activity, int seasonId) {
    Intent mIntent = new Intent(activity, BangumiDetailsActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt(ConstantUtil.EXTRA_BANGUMI_KEY, seasonId);
    mIntent.putExtras(bundle);
    activity.startActivity(mIntent);
  }
}

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

Bundle args = new Bundle();
args.putInt("index", index);
args.putString("type", TYPE_FRAGMENT);
f.setArguments(args);
View view =  inflater.inflate(R.layout.template, container, false);
if(getTypeFragment().equals(ArtistFragment.TYPE_FRAGMENT)){
  view = null;
  view = inflater.inflate(R.layout.artist_details, container, false);

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

@Override
public void onSaveInstanceState(Bundle outState) {

  super.onSaveInstanceState(outState);

  outState.putInt("myInt", myInt);
}

@Override
public View onCreateView(LayoutInflater inflater, 
             ViewGroup container, Bundle savedInstanceState) {

  View view = inflater.inflate(R.layout.my_layout, container);

  if (savedInstanceState != null) {

    myInt = savedInstanceState.getInt("myInt");
  }

  ...

  return view;
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public Message getDialogHandlerMessage() {
  Message msg = Message.obtain();
  msg.what = DialogHandler.MSG_SHOW_DATABASE_ERROR_DIALOG;
  Bundle b = new Bundle();
  b.putInt("dialogType", getArguments().getInt("dialogType"));
  msg.setData(b);
  return msg;
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public Message getDialogHandlerMessage() {
  Message msg = Message.obtain();
  msg.what = DialogHandler.MSG_SHOW_SYNC_ERROR_DIALOG;
  Bundle b = new Bundle();
  b.putInt("dialogType", getArguments().getInt("dialogType"));
  b.putString("dialogMessage", getArguments().getString("dialogMessage"));
  msg.setData(b);
  return msg;
}

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

public class TestFragment extends Fragment {

  private static final String ATAG = "atag";

  public static TestFragment getFragment(int value){
    TestFragment fragment = new TestFragment();
    Bundle bundle = new Bundle();
    bundle.putInt(ATAG, 100);
    fragment.setArguments(bundle);

    return fragment;
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

    View view  = inflater.inflate(R.layout.layout_fragment, container,false);
    Bundle  b = getArguments();
      if(b!= null)
        YOUR DATA = b.getInt(ATAG);
    return view;
  }
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
   Bundle savedInstanceState) 
 {
  View rootView = inflater.inflate(R.layout.first_tab_fragment, container, false); 
  next = (Button)rootView.findViewById(R.id.nextbutton);
  next.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
     // TODO Auto-generated method stub
     Intent intent = new Intent("TAB_CLICKED");
     Bundle bundle = new Bundle();
     bundle.putInt(MainActivity.POSITION,1);
     intent.putExtras(bundle);
     getActivity().sendBroadcast(intent);
   }
  });
 return rootView;
 }

代码示例来源: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(7, finalBundle.getInt("intValue"));
assertEquals(5000000000l, finalBundle.getLong("longValue"));
assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals(1, finalInnerBundle.getInt("inner"));
finalBundle = finalInnerBundle.getBundle("nested bundle");
assertEquals("2", finalBundle.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

public class DetailsFragmentContainer extends Fragment {

public static final String ARG_OBJECT = "details_fragment_container";

Bundle ids;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {

  ids = getArguments();
  View v = inflater.inflate(R.layout.fragments_container, container, false);
  return v;
}

public void createDetailsFragment(int parentItemId) {
  Fragment fragment = new DetailsFragment();
  ids.putInt(Columns.COLUMN_PARENTITEMID, parentItemId);
  fragment.setArguments(ids);
  getChildFragmentManager().beginTransaction().add(R.id.fragments_frame, fragment).commit();
}

}

代码示例来源:origin: ankidroid/Anki-Android

@Override
  public Message getDialogHandlerMessage() {
    Message msg = Message.obtain();
    msg.what = DialogHandler.MSG_SHOW_MEDIA_CHECK_COMPLETE_DIALOG;
    Bundle b = new Bundle();
    b.putStringArrayList("nohave", getArguments().getStringArrayList("nohave"));
    b.putStringArrayList("unused", getArguments().getStringArrayList("unused"));
    b.putStringArrayList("invalid", getArguments().getStringArrayList("invalid"));
    b.putInt("dialogType", getArguments().getInt("dialogType"));
    msg.setData(b);
    return msg;
  }
}

代码示例来源:origin: konmik/nucleus

when(bundle.getChar(anyString(), anyChar())).thenAnswer(getOrDefault);
doAnswer(put).when(bundle).putInt(anyString(), anyShort());
when(bundle.getShort(anyString())).thenAnswer(get);
when(bundle.getShort(anyString(), anyShort())).thenAnswer(getOrDefault);
when(bundle.getDouble(anyString(), anyDouble())).thenAnswer(getOrDefault);
doAnswer(put).when(bundle).putString(anyString(), anyString());
when(bundle.getString(anyString())).thenAnswer(get);
when(bundle.getString(anyString(), anyString())).thenAnswer(getOrDefault);
when(bundle.getIntArray(anyString())).thenAnswer(get);
doAnswer(put).when(bundle).putInt(anyString(), anyInt());
when(bundle.getInt(anyString())).thenAnswer(get);
when(bundle.getInt(anyString(), anyInt())).thenAnswer(getOrDefault);

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

mStackLevel = savedInstanceState.getInt("level");
public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putInt("level", mStackLevel);

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

@Test
public void getWrongType() {
 bundle.putFloat("foo", 5f);
 assertThat(bundle.getCharArray("foo")).isNull();
 assertThat(bundle.getInt("foo")).isEqualTo(0);
 assertThat(bundle.getIntArray("foo")).isNull();
 assertThat(bundle.getIntegerArrayList("foo")).isNull();
 assertThat(bundle.getShort("foo")).isEqualTo((short) 0);
 assertThat(bundle.getShortArray("foo")).isNull();
 assertThat(bundle.getBoolean("foo")).isFalse();
 assertThat(bundle.getBooleanArray("foo")).isNull();
 assertThat(bundle.getLong("foo")).isEqualTo(0);
 assertThat(bundle.getLongArray("foo")).isNull();
 assertThat(bundle.getFloatArray("foo")).isNull();
 assertThat(bundle.getDouble("foo")).isEqualTo(0.0);
 assertThat(bundle.getDoubleArray("foo")).isNull();
 assertThat(bundle.getString("foo")).isNull();
 assertThat(bundle.getStringArray("foo")).isNull();
 assertThat(bundle.getStringArrayList("foo")).isNull();
 assertThat(bundle.getBundle("foo")).isNull();
 assertThat((Parcelable) bundle.getParcelable("foo")).isNull();
 assertThat(bundle.getParcelableArray("foo")).isNull();
 assertThat(bundle.getParcelableArrayList("foo")).isNull();
 bundle.putInt("foo", 1);
 assertThat(bundle.getFloat("foo")).isEqualTo(0.0f);
}

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

View view= inflater.inflate(R.layout.layout_main, container, false);
return view;
Bundle args = new Bundle();
args.putInt("year", calender.get(Calendar.YEAR));
args.putInt("month", calender.get(Calendar.MONTH));
args.putInt("day", calender.get(Calendar.DAY_OF_MONTH));
date.setArguments(args);

相关文章

Bundle类方法