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


Java View.getContext方法代码示例

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


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

示例1: onCreateView

import android.view.View; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);
    Bundle data = getArguments();
    int cellLayout = data.getInt(ARG_LAYOUT);
    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        adapter = new JournalAdapter(selectedTrips, cellLayout, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:23,代码来源:JournalFragment.java

示例2: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    DummyContent.DummyItem item = (DummyContent.DummyItem) view.getTag();
    if (mTwoPane) {
        Bundle arguments = new Bundle();
        arguments.putString(ItemDetailFragment.ARG_ITEM_ID, item.id);
        ItemDetailFragment fragment = new ItemDetailFragment();
        fragment.setArguments(arguments);
        mParentActivity.getSupportFragmentManager().beginTransaction()
                .replace(R.id.item_detail_container, fragment)
                .commit();
    } else {
        Context context = view.getContext();
        Intent intent = new Intent(context, ItemDetailActivity.class);
        intent.putExtra(ItemDetailFragment.ARG_ITEM_ID, item.id);

        context.startActivity(intent);
    }
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:20,代码来源:ItemListActivity.java

示例3: wrap

import android.view.View; //导入方法依赖的package包/类
public static DStateLayout wrap(View view) {
  if (view == null) {
    throw new RuntimeException("content view can not be null");
  }
  ViewGroup parent = (ViewGroup) view.getParent();
  if (parent == null) {
    throw new RuntimeException("parent view can not be null");
  }
  ViewGroup.LayoutParams lp = view.getLayoutParams();
  int index = parent.indexOfChild(view);
  parent.removeView(view);

  DStateLayout layout = new DStateLayout(view.getContext());
  parent.addView(layout, index, lp);
  layout.addView(view);
  layout.setContentView(view);
  return layout;
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:19,代码来源:DStateLayout.java

示例4: BasePopupWindowForListView

import android.view.View; //导入方法依赖的package包/类
public BasePopupWindowForListView(View contentView, int width, int height,
                                  boolean focusable, List<T> mDatas, Object... params) {
    super(contentView, width, height, focusable);
    this.mContentView = contentView;
    context = contentView.getContext();
    if (mDatas != null)
        this.mDatas = mDatas;

    if (params != null && params.length > 0) {
        beforeInitWeNeedSomeParams(params);
    }

    setBackgroundDrawable(new BitmapDrawable());
    setTouchable(true);
    setOutsideTouchable(true);
    setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                dismiss();
                return true;
            }
            return false;
        }
    });
    initViews();
    initEvents();
    init();
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:30,代码来源:BasePopupWindowForListView.java

示例5: onLongClick

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
    PopupMenu menu = new PopupMenu(v.getContext(), v);
    menu.getMenu().add(0, CONTEXT_MENU_FILTER_ID, 0, R.string.filter_choice);
    menu.getMenu().add(0, CONTEXT_MENU_COPY_ID, 0, R.string.copy_to_clipboard);
    menu.setOnMenuItemClickListener(LogLineViewHolder.this);
    menu.show();
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:LogLineViewHolder.java

示例6: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    BaseActivity activity = (BaseActivity) v.getContext();
    activity.send(new ToggleRequest(entity, stateSwitch.isChecked()), (success, result) -> activity.runOnUiThread(() -> {
        if (success) {
            entity.state = HassUtils.getOnState(entity, stateSwitch.isChecked());
            updateColor();
        } else {
            stateSwitch.toggle();
        }
    }));
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:13,代码来源:SwitchViewHolder.java

示例7: ContextViewBlock

import android.view.View; //导入方法依赖的package包/类
protected ContextViewBlock(View blockingView) {
    Preconditions.checkNotNull(blockingView);
    this.mBlockingView = blockingView;
    mBlockingViewId = blockingView.getId();
    this.mContext = blockingView.getContext();
    this.mActivity = (Activity) this.mContext;
    onAttachToActivity(mActivity);
}
 
开发者ID:iflove,项目名称:UIKit-ViewBlock,代码行数:9,代码来源:ContextViewBlock.java

示例8: createView

import android.view.View; //导入方法依赖的package包/类
public final View createView(View parent, final String name, @NonNull Context context,
                             @NonNull AttributeSet attrs, boolean inheritContext,
                             boolean readAndroidTheme, boolean readAppTheme) {
    // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy
    // by using the parent's context
    if (inheritContext && parent != null) {
        context = parent.getContext();
    }
    if (readAndroidTheme || readAppTheme) {
        // We then apply the theme on the context, if specified
        context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
    }

    View view = createViewFromHackInflater(context, name, attrs);

    // We need to 'inject' our tint aware Views in place of the standard framework versions
    if (view == null) {
        view = createViewFromFV(context, name, attrs);
    }

    if (view == null) {
        view = createViewFromInflater(context, name, attrs);
    }

    if (view == null) {
        view = createViewFromTag(context, name, attrs);
    }

    if (view != null) {
        // If we have created a view, check it's android:onClick
        checkOnClickListener(view, attrs);
    }

    return view;
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:36,代码来源:SkinCompatViewInflater.java

示例9: onClick

import android.view.View; //导入方法依赖的package包/类
@Override public void onClick(View view) {
    // Check if the user is signed in:
    boolean isSignedIn = FirebaseHelper.signInIfNeeded((MainActivity)getActivity());
    // Don't do anything if the user isn't signed in:
    if (!isSignedIn) return;

    // Close the plus button menu
    FloatingActionMenu floatingMenu = (FloatingActionMenu) rootView.findViewById(R.id.menu);
    floatingMenu.close(false);

    // Open the activity (which masquerades as a dialog)
    Intent intent = new Intent(view.getContext(), DriverDialog.class);
    intent.putExtra("driverId", "");
    startActivity(intent);
}
 
开发者ID:brianjaustin,项目名称:permitlog-android,代码行数:16,代码来源:HomeFragment.java

示例10: onCreateView

import android.view.View; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_column_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.setAdapter(new ColumnRecyclerViewAdapter(mList, mListener));
    }
    return view;
}
 
开发者ID:BobbyZhang93,项目名称:BestBlog,代码行数:15,代码来源:ColumnFragment.java

示例11: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    MaterialColorSetting entry = getEntry();
    MaterialColorPickerDialog dialog = new MaterialColorPickerDialog(v.getContext());
    dialog.setTitle(entry.mName);
    dialog.setColorPickListener(entry::setSelectedColor);
    dialog.show();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:9,代码来源:MaterialColorSetting.java

示例12: BlurTask

import android.view.View; //导入方法依赖的package包/类
public BlurTask(View target, BlurFactor factor, Callback callback) {
  this.res = target.getResources();
  this.factor = factor;
  this.callback = callback;
  this.contextWeakRef = new WeakReference<>(target.getContext());

  target.setDrawingCacheEnabled(true);
  target.destroyDrawingCache();
  target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  bitmap = target.getDrawingCache();
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:12,代码来源:BlurTask.java

示例13: showPanel

import android.view.View; //导入方法依赖的package包/类
public static void showPanel(View panelLayout) {
    Activity activity = (Activity) panelLayout.getContext();
    panelLayout.setVisibility(0);
    if (activity.getCurrentFocus() != null) {
        KeyboardUtil.hideKeyboard(activity.getCurrentFocus());
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:KPSwitchConflictUtil.java

示例14: onCreateView

import android.view.View; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recyclerview_with_restore, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.setAdapter(new MyItemRecyclerViewAdapter(DummyContent.ITEMS, mListener));
    }
    return view;
}
 
开发者ID:Kaufland,项目名称:andswipeframework,代码行数:15,代码来源:RecylerViewWithRestoreFragment.java

示例15: InfoBeanViewHolder

import android.view.View; //导入方法依赖的package包/类
InfoBeanViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    context = itemView.getContext();
    setupRvMetaInfo();
    tvOriginText.setVisibility(View.GONE);
    mShortAnimationDuration = context.getResources().getInteger(
            android.R.integer.config_shortAnimTime);
}
 
开发者ID:jonashao,项目名称:Samantha,代码行数:10,代码来源:InfoBeanViewHolder.java


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