本文整理汇总了Java中android.app.Fragment.setArguments方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.setArguments方法的具体用法?Java Fragment.setArguments怎么用?Java Fragment.setArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Fragment
的用法示例。
在下文中一共展示了Fragment.setArguments方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectItem
import android.app.Fragment; //导入方法依赖的package包/类
private void selectItem(int position) {
// update the main content by replacing fragments
Fragment fragment = new PlanetFragment();
Bundle args = new Bundle();
args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
fragment.setArguments(args);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// update selected item and title, then close the drawer
mLeftDrawer.setItemChecked(position, true);
setTitle(mContent[position]);
mDlMain.closeDrawer(mLeftDrawer);
}
示例2: changeFragment
import android.app.Fragment; //导入方法依赖的package包/类
public void changeFragment(String tag) {
mBackPressListener = null;
Fragment fragment = null;
if (FRAGMENT_GRID.equals(tag)) {
fragment = new VideoGridFragment();
fragment.setArguments(getIntent().getExtras());
mBackPressListener = (VideoGridFragment) fragment;
}
if (fragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.container, fragment, tag);
transaction.commit();
}
}
示例3: prepare
import android.app.Fragment; //导入方法依赖的package包/类
public void prepare(Fragment toFragment) {
final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap);
if (Build.VERSION.SDK_INT >= 21) {
toFragment.setSharedElementEnterTransition(new ChangeBounds());
toFragment.setSharedElementReturnTransition(new ChangeBounds());
}
toFragment.setArguments(transitionBundle);
}
示例4: newInstance
import android.app.Fragment; //导入方法依赖的package包/类
public static Fragment newInstance(String text) {
Fragment fragment = new SampleFragmentV11();
Bundle bundle = new Bundle();
bundle.putString(KEY_TEXT, text);
fragment.setArguments(bundle);
return fragment;
}
示例5: openScreen
import android.app.Fragment; //导入方法依赖的package包/类
@Override public void openScreen(Module module, Screen screen, boolean clear) {
if (clear) popBackStack();
Fragment fragment = buildFragment(screen.getFragmentClass());
fragment.setArguments(screen.getData());
FragmentTransaction transaction = fragmentManager.get().beginTransaction();
transaction.replace(module.provideContainer(), fragment);
transaction.addToBackStack(screen.getFragmentClass().getSimpleName());
if (activity instanceof TransactionManagerDefault)
((TransactionManagerDefault) activity).manage(transaction);
transaction.commit();
}
示例6: setFragmentArgs
import android.app.Fragment; //导入方法依赖的package包/类
private void setFragmentArgs(Fragment frag) {
Bundle bundle = new Bundle();
String key = MobileClient.EXTRA_USER;
MobileClient value = getIntent().getParcelableExtra(MobileClient.EXTRA_USER);
bundle.putParcelable(key, value);
frag.setArguments(bundle);
}
示例7: navigate
import android.app.Fragment; //导入方法依赖的package包/类
private void navigate(final int itemId) {
switch (itemId) {
case R.id.menuSubItem1:
Fragment contactsFrag = new ContactsFragment();
Bundle bundle = new Bundle();
String key = MobileClient.EXTRA_USER;
MobileClient value = getIntent().getParcelableExtra(MobileClient.EXTRA_USER);
bundle.putParcelable(key, value);
contactsFrag.setArguments(bundle);
getFragmentManager()
.beginTransaction()
.remove(contactsFrag)
.replace(R.id.subContentFrame, contactsFrag)
.commit();
break;
case R.id.menuSubItem2:
getFragmentManager()
.beginTransaction()
.replace(R.id.subContentFrame, requestSubsFrag)
.commit();
break;
case R.id.menuSubItem3:
SessionManager manager = new SessionManager(this);
manager.logoutUser();
break;
default:
break;
}
}
示例8: setView
import android.app.Fragment; //导入方法依赖的package包/类
/**
* Set the view to a certain fragment. Changes the subtitle as well.
*
* @param i The view type constant
* @param args The parameters for the fragment
*/
private void setView(int i, Bundle args) {
final Fragment frg;
switch (i) {
default:
case VIEW_TYPE_LIVEBOARD:
frg = LiveboardSearchFragment.newInstance();
setSubTitle(R.string.title_liveboard);
break;
case VIEW_TYPE_ROUTE:
frg = RouteSearchFragment.newInstance();
setSubTitle(R.string.title_route);
break;
case VIEW_TYPE_TRAIN:
frg = TrainSearchFragment.newInstance();
setSubTitle(R.string.title_train);
break;
case VIEW_TYPE_DISTURBANCE:
frg = DisturbanceListFragment.newInstance();
setSubTitle(R.string.title_disturbances);
break;
case VIEW_TYPE_FEEDBACK:
frg = FeedbackFragment.newInstance();
setSubTitle(R.string.title_feedback);
break;
}
if (args != null) {
frg.setArguments(args);
}
mCurrentFragment = frg;
mCurrentView = i;
getFragmentManager().beginTransaction().replace(R.id.fragment_container, frg, "ChildViewTag").commit();
}
示例9: onItemClick
import android.app.Fragment; //导入方法依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle data = new Bundle();
Fragment newFragment = new InitiativeDetail();
Initiative initiat = initiativeList.get(position);
data.putParcelable(DETAIL, initiat);
newFragment.setArguments(data);
FragmentTransaction transaction = getActivity().getFragmentManager().beginTransaction();
transaction.replace(R.id.container, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
示例10: onPostExecute
import android.app.Fragment; //导入方法依赖的package包/类
@Override
protected void onPostExecute(ArrayList<Initiative> result) {
super.onPostExecute(result);
progDailog.dismiss();
boolean insideList = false;
if(fragment != null){
insideList = true;
}
if(result != null) {
if(insideList){
fragment.getInitiativeList().clear();
fragment.getInitiativeList().addAll(result);
((BaseAdapter) fragment.getmListView().getAdapter()).notifyDataSetChanged();
}else {
Bundle data = new Bundle();
data.putParcelableArrayList("result", result);
Log.v(TAG, "result= " + result);
Fragment newFragment = new InitiativeFragment();
newFragment.setArguments(data);
FragmentTransaction transaction = context.getFragmentManager().beginTransaction();
transaction.replace(R.id.container, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
}else{
if(insideList){
Toast.makeText(context,
R.string.get_initiatives_error_list, Toast.LENGTH_LONG)
.show();
}else {
Toast.makeText(context,
R.string.get_initiatives_error, Toast.LENGTH_LONG)
.show();
}
}
}