本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
}));
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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());
}
}
示例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;
}
示例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);
}