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


Java Fragment.getActivity方法代码示例

本文整理汇总了Java中android.app.Fragment.getActivity方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.getActivity方法的具体用法?Java Fragment.getActivity怎么用?Java Fragment.getActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Fragment的用法示例。


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

示例1: stopApplication

import android.app.Fragment; //导入方法依赖的package包/类
public static void stopApplication(final Fragment fragment) {
	final String tag = "stopApplication - ";
	final int waitTime = 5000;

	Analytics.getInstance().logEvent(TAG, "stopApplication", "");

	if (fragment != null && fragment.getActivity() != null) {
		fragment.getActivity().finish();

		try {
			Thread.sleep(waitTime);
		} catch (InterruptedException e) {
			Log.e(TAG,tag,e);
		}
	}

	System.exit(0);
}
 
开发者ID:videgro,项目名称:Ships,代码行数:19,代码来源:FragmentUtils.java

示例2: setParentFragmentHint

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Sets a hint for which fragment is our parent which allows the fragment to return correct
 * information about its parents before pending fragment transactions have been executed.
 */
void setParentFragmentHint(Fragment parentFragmentHint) {
  this.parentFragmentHint = parentFragmentHint;
  if (parentFragmentHint != null && parentFragmentHint.getActivity() != null) {
    registerFragmentWithRoot(parentFragmentHint.getActivity());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:RequestManagerFragment.java

示例3: parse

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * 透过Fragment解析LKUI注解
 * 可以通过注解配置contentView,field的id等
 */
public static View parse(Fragment fragment, LayoutInflater inflater, ViewGroup container, boolean ignoreNoFindViewField) {
    View rView = null;
    try {
        // 解析类注解:SetContentView
        SetContentView setContentView = fragment.getClass().getAnnotation(SetContentView.class);
        if (setContentView != null && setContentView.value() > 0)
            // 可以读到SetContentView的layout的id值
            rView = inflater.inflate(setContentView.value(), container, false);
        // 解析属性注解:FindView
        Field[] fields = fragment.getClass().getDeclaredFields();
        for (Field fieldItem : fields) {
            fieldItem.setAccessible(true);
            if (!(View.class.isAssignableFrom(fieldItem.getType())))
                continue;
            FindView findView = fieldItem.getAnnotation(FindView.class);
            if (findView != null)
                // 配置了FindView注解
                if (findView.value() > 0)
                    fieldItem.set(fragment, container.findViewById(findView.value()));
                else // 如果没有设置view的id,那么自动尝试以属性名作为id进行查询赋值
                    fieldItem.set(fragment, LKResourceTool.findViewByIdStr(rView, fieldItem.getName()));
            else if (!ignoreNoFindViewField)// 没有配置FindView注解并且没有设置忽略无注解属性(ignoreNoFindViewField为false),尝试以属性名作为id,进行查询赋值
                fieldItem.set(fragment, LKResourceTool.findViewByIdStr(rView, fieldItem.getName()));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return rView == null ? new View(fragment.getActivity()) : rView;
}
 
开发者ID:LemonAppCN,项目名称:LemonKit4Android,代码行数:34,代码来源:LKUIAnnotationParser.java

示例4: forFragment

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * @param fragment {@link Fragment} invoking the integration.
 *                 {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
 *                 of an {@link Activity}
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static IntentIntegrator forFragment(Fragment fragment) {
    IntentIntegrator integrator = new IntentIntegrator(fragment.getActivity());
    integrator.fragment = fragment;
    return integrator;
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:12,代码来源:IntentIntegrator.java

示例5: Overlay

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Must be created from the Fragment onViewCreated() method
 * @param fragment
 */
public Overlay(Fragment fragment) {

    if (!fragment.isAdded()) {
        throw new IllegalStateException("Overlay must be created once the fragment is added!");
    }

    mContext = fragment.getActivity();
    ViewGroup fragmentView = (ViewGroup)fragment.getView();
    if (fragmentView==null) {
        throw new IllegalStateException("Overlay must be created once the fragment has its view created!");
    }

    int parentViewId = -1;
    if (fragment instanceof BrowseFragment) {
        parentViewId = R.id.browse_frame;
    } else if (fragment instanceof MyVerticalGridFragment) {
        parentViewId = R.id.browse_dummy;
    } else if (fragment instanceof DetailsFragment) {
        parentViewId = R.id.details_fragment_root;
    } else if (fragment instanceof GuidedStepFragment) {
        parentViewId = R.id.guidedstep_background_view_root;
    } else {
        throw new IllegalStateException("Overlay is not compatible with this fragment: "+fragment);
    }

    ViewGroup parentView = (ViewGroup)fragmentView.findViewById(parentViewId);
    if (parentView==null) {
        throw new IllegalStateException("parentView not found! Maybe IDs in the leanback library have been changed?");
    }

    LayoutInflater.from(mContext).inflate(R.layout.leanback_overlay, parentView);
    mOverlayRoot = parentView.findViewById(R.id.overlay_root);
    mScanProgress = new ScannerAndScraperProgress(mContext, mOverlayRoot);
    mClock = new Clock(mContext, mOverlayRoot);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:40,代码来源:Overlay.java

示例6: camera

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Open the camera from the activity.
 */
public static Camera<ImageCameraWrapper, VideoCameraWrapper> camera(Fragment fragment) {
    return new AlbumCamera(fragment.getActivity());
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:7,代码来源:Album.java

示例7: image

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Select images.
 */
public static Choice<ImageMultipleWrapper, ImageSingleWrapper> image(Fragment fragment) {
    return new ImageChoice(fragment.getActivity());
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:7,代码来源:Album.java

示例8: get

import android.app.Fragment; //导入方法依赖的package包/类
public static DocumentsActivity get(Fragment fragment) {
    return (DocumentsActivity) fragment.getActivity();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:4,代码来源:DocumentsActivity.java

示例9: IntentIntegrator

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * @param fragment {@link Fragment} invoking the integration.
 *  {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
 *  of an {@link Activity}
 */
public IntentIntegrator(Fragment fragment) {
    this.activity = fragment.getActivity();
    this.fragment = fragment;
    initializeConfiguration();
}
 
开发者ID:sd1998,项目名称:QR-Code-Reader,代码行数:11,代码来源:IntentIntegrator.java

示例10: album

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Select images and videos.
 */
public static Choice<AlbumMultipleWrapper, AlbumSingleWrapper> album(Fragment fragment) {
    return new AlbumChoice(fragment.getActivity());
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:7,代码来源:Album.java

示例11: IntentIntegrator

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * @param fragment {@link Fragment} invoking the integration.
 *                 {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
 *                 of an {@link Activity}
 */
public IntentIntegrator(Fragment fragment) {
    this.activity = fragment.getActivity();
    this.fragment = fragment;
    initializeConfiguration();
}
 
开发者ID:anikraj1994,项目名称:Remote,代码行数:11,代码来源:IntentIntegrator.java

示例12: init

import android.app.Fragment; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public static SmartAdapterBuilder init(@NonNull Fragment caller) {
    return new SmartAdapterBuilder(caller, caller.getActivity());
}
 
开发者ID:manneohlund,项目名称:smart-recycler-adapter,代码行数:5,代码来源:SmartRecyclerAdapter.java

示例13: FragmentCallImpl

import android.app.Fragment; //导入方法依赖的package包/类
FragmentCallImpl(Fragment fragment) {
  super(fragment.getActivity());
  this.fragment = fragment;
}
 
开发者ID:BiaoWu,项目名称:IntentRouter,代码行数:5,代码来源:FragmentCallImpl.java

示例14: get

import android.app.Fragment; //导入方法依赖的package包/类
public static BaseActivity get(Fragment fragment) {
    return (BaseActivity) fragment.getActivity();
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:4,代码来源:StandaloneActivity.java

示例15: galleryAlbum

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * Preview Album.
 */
public static BasicGalleryWrapper<GalleryAlbumWrapper, AlbumFile, String, AlbumFile> galleryAlbum(Fragment fragment) {
    return new GalleryAlbumWrapper(fragment.getActivity());
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:7,代码来源:Album.java


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