當前位置: 首頁>>代碼示例>>Java>>正文


Java AppCompatActivity類代碼示例

本文整理匯總了Java中android.support.v7.app.AppCompatActivity的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatActivity類的具體用法?Java AppCompatActivity怎麽用?Java AppCompatActivity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AppCompatActivity類屬於android.support.v7.app包,在下文中一共展示了AppCompatActivity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onActivityResult

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == AppCompatActivity.RESULT_OK) {
        Uri imageUri = CropImage.getPickImageResultUri(this, data);

        // For API >= 23 we need to check specifically that we have permissions to read external storage,
        // but we don't know if we need to for the URI so the simplest is to try open the stream and see if we get error.
        boolean requirePermissions = false;
        if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {

            // request permissions and handle the result in onRequestPermissionsResult()
            requirePermissions = true;
            mCropImageUri = imageUri;
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {

            mCurrentFragment.setImageUri(imageUri);
        }
    }
}
 
開發者ID:chuch0805,項目名稱:Android-Demo_ImageCroper,代碼行數:24,代碼來源:MainActivity.java

示例2: init

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
private void init(View view) {
    unbinder = ButterKnife.bind(this, view);
    activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);

    animation = AnimationUtils.loadAnimation(activity, R.anim.fade_in);
    animation.setDuration(1000);

    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
    }

    tryAgainBtn.setOnClickListener(v -> presenter.onPersonDetailRequested(personId));
}
 
開發者ID:prakh25,項目名稱:MovieApp,代碼行數:17,代碼來源:PeopleDetailFragment.java

示例3: BeaconViewFragment

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
public BeaconViewFragment() {
    deviceLocationListener = createDeviceLocationListener();
    beaconUpdateListener = createBeaconUpdateListener();
    closestGateChangeListener = new ClosestGateChangeListener() {
        @Override
        public void onClosestGateDistanceChanged(GateGroup gateGroup, Gate gate, float distance) {
            Log.v("Gate", "Closest gate distance changed to: " + String.format("%.2f", distance) + " meters");
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Gate " + gate.getIndex() + " - " + String.format("%.2f", distance) + "m");
        }

        @Override
        public void onClosestGateChanged(GateGroup gateGroup, Gate gate, float distance) {
            Log.d("Gate", "Closest gate changed to: " + gate);
        }

        @Override
        public void onClosestGateGroupChanged(GateGroup gateGroup, Gate gate, float distance) {
            Log.d("Gate", "Closest gate group changed to: " + gateGroup);
        }
    };
}
 
開發者ID:neXenio,項目名稱:BLE-Indoor-Positioning,代碼行數:22,代碼來源:BeaconViewFragment.java

示例4: onAttach

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    Fragment fragment = ((AppCompatActivity) context).getSupportFragmentManager()
            .findFragmentByTag(getArguments().getString(ARG_PARENT_FRAGMENT));
    if (fragment != null) {
        if (fragment instanceof OnImagePickedListener) {
            listener = (OnImagePickedListener) fragment;
        }
    } else {
        if (context instanceof OnImagePickedListener) {
            listener = (OnImagePickedListener) context;
        }
    }

    if (listener == null) {
        throw new IllegalStateException("Either activity or fragment should implement OnImagePickedListener");
    }
}
 
開發者ID:mobilemaster128,項目名稱:quickblox-android,代碼行數:20,代碼來源:ImagePickHelperFragment.java

示例5: onDetachedFromWindow

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();

    AppCompatActivity activity = (AppCompatActivity) getContext();
    if (activity == null) {
        throw new IllegalArgumentException("Cannot add a SettingsView to activities which are not an AppCompatActivity");
    }

    Fragment existingFragment = activity.getSupportFragmentManager().findFragmentByTag("preferences-fragment");
    if (existingFragment == null) {
        return;
    }

    if (currentTransaction == null) {
        currentTransaction = activity.getSupportFragmentManager().beginTransaction();
    }
    currentTransaction.remove(existingFragment);
    currentTransaction.commitAllowingStateLoss();
    currentTransaction = null;
    activity.getSupportFragmentManager().executePendingTransactions();
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:23,代碼來源:SettingsView.java

示例6: getStatusBarHeight

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
private static int getStatusBarHeight(AppCompatActivity activity) {
    Class<?> c;
    Object obj;
    Field field;
    int x;
    int statusBarHeight = 0;
    try {
        c = Class.forName("com.android.internal.R$dimen");
        obj = c.newInstance();
        field = c.getField("status_bar_height");
        x = Integer.parseInt(field.get(obj).toString());
        statusBarHeight = activity.getResources().getDimensionPixelSize(x);
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    return statusBarHeight;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:18,代碼來源:ScreenUtil.java

示例7: init

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
private void init(View view) {
    unbinder = ButterKnife.bind(this, view);

    activity = (AppCompatActivity) getActivity();

    activity.setSupportActionBar(toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(title);
    }

    LinearLayoutManager layoutManager
            = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new DividerItemDecoration(activity, layoutManager.getOrientation()));
    recyclerView.setHasFixedSize(true);
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(genreAdapter);
}
 
開發者ID:prakh25,項目名稱:MovieApp,代碼行數:24,代碼來源:GenreFragment.java

示例8: TitleLayout

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
public TitleLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.include_title_layout, this);
    //
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    //
    ((AppCompatActivity) getContext()).setSupportActionBar(toolbar);
    ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
    if (actionBar != null) {
        //是否顯示默認Title
        actionBar.setDisplayShowTitleEnabled(true);
        //是否顯示返回鍵
        actionBar.setDisplayHomeAsUpEnabled(true);
        //監聽返回鍵
        toolbar.setNavigationOnClickListener(view -> ((AppCompatActivity) getContext()).onBackPressed());
    }
}
 
開發者ID:zhao-mingjian,項目名稱:qvod,代碼行數:18,代碼來源:TitleLayout.java

示例9: OrgHolder

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
public OrgHolder(View itemView) {
    super(itemView);
    orgImage = itemView.findViewById(R.id.org_image);
    orgCard = itemView.findViewById(R.id.card_view_org);
    orgName = itemView.findViewById(R.id.org_name);
    orgTagline = itemView.findViewById(R.id.org_tagline);

    orgCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(context, OrgDetailActivity.class);
            i.putExtra(ORG_TAG, getItem(getAdapterPosition()));
            i.putExtra("EXTRA_TRANSITION_NAME", ViewCompat.getTransitionName(orgImage));
            ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((AppCompatActivity) context,
                    orgImage,
                    ViewCompat.getTransitionName(orgImage));
            i.putExtra("ORG_ID", getItem(getAdapterPosition()).getOrgID());
            context.startActivity(i, optionsCompat.toBundle());
        }
    });
}
 
開發者ID:coding-blocks,項目名稱:GSoC-Info-Android,代碼行數:22,代碼來源:OrgAdapter.java

示例10: showIntroDialog

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
public static void showIntroDialog(final AppCompatActivity activity) {

        RadioDialogCallback callback = new RadioDialogCallback() {
            @Override
            public void which(int position) {
                if (position == 0) {
                    activity.startActivity(IntroActivity.previewIntroInstance(activity));
                    activity.finish();
                } else {
                    activity.startActivity(IntroActivity.todoListIntroInstance(activity, null, null));
                    activity.finish();
                }
            }
        };

        CharSequence[] items = new CharSequence[]{
                getString(activity, R.string.intro_preview),
                getString(activity, R.string.intro_todo_list),
        };
        showRadioDialog(activity, getString(activity, R.string.intro_dialog), items, callback);
    }
 
開發者ID:djuelg,項目名稱:Neuronizer,代碼行數:22,代碼來源:RadioDialogs.java

示例11: onPostExecute

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@Override
protected void onPostExecute(Boolean aBoolean) {
    super.onPostExecute(aBoolean);
    if (aBoolean && mContext.get() != null && !((AppCompatActivity) mContext.get()).isFinishing()) {
        if (mWallpaper.getSize() <= 0) {
            File target = ImageLoader.getInstance().getDiskCache().get(mWallpaper.getUrl());
            if (target.exists()) {
                mWallpaper.setSize((int) target.length());
            }
        }
    }

    if (mCallback != null && mCallback.get() != null) {
        mCallback.get().onPropertiesReceived(mWallpaper);
    }
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:17,代碼來源:WallpaperPropertiesLoaderTask.java

示例12: getViewModel

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@NonNull
public static <T> T getViewModel(AppCompatActivity activity, String viewModelTag) {
    ViewModelHolder viewModelHolder = (ViewModelHolder) activity.getSupportFragmentManager().findFragmentByTag(viewModelTag);
    if(viewModelHolder == null) {
        throw new IllegalStateException("View model holder for [" + viewModelTag + "] does not exist");
    }
    T viewModel = viewModelHolder.getViewModel();
    if(viewModel == null) {
        throw new IllegalStateException("View model for [" + viewModelTag + "] does not exist");
    }
    return viewModel;
}
 
開發者ID:Zhuinden,項目名稱:simple-stack,代碼行數:13,代碼來源:ViewModelLifecycleHelper.java

示例13: RegionViewHolder

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
RegionViewHolder(View itemView) {
    super(itemView);
    tvNombreRegion = (TextView) itemView.findViewById(R.id.tv_nombre_region);
    tvDireccionRegion = (TextView) itemView.findViewById(R.id.tv_direccion_region);

    itemView.setOnClickListener(v -> {
        DetalleRegionFragment f = DetalleRegionFragment.newInstance(regiones.get(getAdapterPosition()).getIdRegion());
        FragmentManager fragmentManager = ((AppCompatActivity)context).getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.segunda_fragment_container, f).addToBackStack(null).commit();
    });
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:13,代碼來源:RVRegionAdapter.java

示例14: onCreate

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activity = ((AppCompatActivity) getActivity());
    toolbar = (Toolbar) activity.findViewById(R.id.toolbar2);
    cToolBar = (CollapsingToolbarLayout) activity.findViewById(R.id.collapsing_toolbar);
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:8,代碼來源:PromocionFragment.java

示例15: launch

import android.support.v7.app.AppCompatActivity; //導入依賴的package包/類
private void launch(AppCompatActivity activity, View transitionView, int resId) {


        Pair squareParticipant = new Pair<>(transitionView, ViewCompat.getTransitionName(transitionView));
        ActivityOptionsCompat transitionActivityOptions =
                ActivityOptionsCompat.makeSceneTransitionAnimation(
                        activity, squareParticipant);
        Intent intent = new Intent(
                activity, ViewerActivity.class);
        intent.putExtra("resId", resId);
        startActivity(intent, transitionActivityOptions.toBundle());
    }
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:13,代碼來源:ShareTractionActivity.java


注:本文中的android.support.v7.app.AppCompatActivity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。