本文整理汇总了Java中android.view.ViewGroup.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.getContext方法的具体用法?Java ViewGroup.getContext怎么用?Java ViewGroup.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
Log.d(TAG, "onCreateViewHolder");
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
/*
* This template uses a default image in res/drawable, but the general case for Android TV
* will require your resources in xhdpi. For more information, see
* https://developer.android.com/training/tv/start/layouts.html#density-resources
*/
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}
示例2: instantiateItem
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public View instantiateItem(ViewGroup container, final int position) {
PhotoView photoView = new PhotoView(container.getContext());
//load full size image with Picasso lib into the photoView
Picasso.with(container.getContext())
.load(sDrawables.get(position).getPhoto().getOriginalSize().getUrl())
.placeholder(R.drawable.ic_sync)
.error(R.drawable.ic_warning)
.into(photoView);
container.addView(photoView, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@Override
public void onViewTap(final View view, float x, float y) {
//on photo click, display or hide data section
View photoDataView = findViewById(R.id.photo_data);
if (photoDataView.getVisibility() == View.VISIBLE) {
photoDataView.setVisibility(View.GONE);
} else {
photoDataView.setVisibility(View.VISIBLE);
}
}
});
return photoView;
}
示例3: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public MyComicNumberHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
context = parent.getContext();
final MyComicNumberHolder comicNumberHolder = new MyComicNumberHolder(LayoutInflater.from(context).inflate(R.layout.comic_number_recyclerview,parent,false));
comicNumberHolder.view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = comicNumberHolder.getAdapterPosition();
ComicNumberList comicNumberList = comicNumberLists.get(position);
comicNumberHolder.comicNumberCardview.setCardBackgroundColor(ContextCompat.getColor(context,R.color.colorPrimary));
ContentValues values = new ContentValues();
values.put("readNow",comicNumberList.getComicPages());
DataSupport.updateAll(ComicMessageItem.class,values,"comicUrl = ?",comicNumberList.getComicUrl());
//Log.d("readnow",DataSupport.where("comicUrl = ?",comicNumberList.getComicUrl()).find(ComicMessageItem.class).get(0).getReadNow());
Intent intent = new Intent(context, ComicReadActivity.class);
intent.putExtra(ComicFragment.COMICREADURL,comicNumberList.getComicPagesUrl());
context.startActivity(intent);
}
});
return comicNumberHolder;
}
示例4: hookNavBar
import android.view.ViewGroup; //导入方法依赖的package包/类
private static void hookNavBar(ViewGroup rootView, ViewGroup navbarView) {
rootNavbarView = rootView;
Context context = rootView.getContext();
ViewPager vpXpHook = new ViewPager(context);
exNavbar = new LinearLayout(context);
musicControllerPanel = new MusicControllerPanel(context);
onHomeNavbar = new LinearLayout(context);
initExNavbar(vpXpHook, exNavbar);
initHomeNavbar(onHomeNavbar, vpXpHook);
initMusicPanel(musicControllerPanel);
initVpHook(vpXpHook, navbarView, exNavbar, musicControllerPanel, onHomeNavbar);
initBroadcast(context);
initClipBoardListener(context);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
rootView.addView(vpXpHook, 0, params);
setNavbarHeight(context, DataHook.navbarHeight);
}
示例5: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
*
* This gets called when each new ViewHolder is created. This happens when the RecyclerView
* is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling.
*
* @param viewGroup The ViewGroup that these ViewHolders are contained within.
* @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you
* can use this viewType integer to provide a different layout. See
* {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)}
* for more details.
* @return A new NumberViewHolder that holds the View for each list item
*/
@Override
public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
Context context = viewGroup.getContext();
int layoutIdForListItem = R.layout.number_list_item;
LayoutInflater inflater = LayoutInflater.from(context);
boolean shouldAttachToParentImmediately = false;
View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately);
NumberViewHolder viewHolder = new NumberViewHolder(view);
viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount);
int backgroundColorForViewHolder = ColorUtils
.getViewHolderBackgroundColorFromInstance(context, viewHolderCount);
viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder);
viewHolderCount++;
Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: "
+ viewHolderCount);
return viewHolder;
}
示例6: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public FloatViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View itemView = inflater.inflate(R.layout.float_status_view, parent, false);
// int height = parent.getMeasuredHeight() / 4;
// int width = parent.getMinimumWidth() /3;
// itemView.setMinimumHeight(height);
// itemView.setMinimumWidth(width);
return new FloatAdapter.FloatViewHolder(itemView);
}
示例7: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LinearLayout linearLayout = new LinearLayout(parent.getContext());
linearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
return new ViewHolder(linearLayout) {
};
}
示例8: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ImageHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext();
View view = LayoutInflater.from(context).inflate
(R.layout.item_imgselector_pop, parent, false);
return new ImageHolder(view);
}
示例9: build
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public FocusBorder build(ViewGroup parent)
{
if (null == parent)
{
throw new NullPointerException("The FocusBorder parent cannot be null");
}
final ColorFocusBorder boriderView =
new ColorFocusBorder(parent.getContext(), mShimmerColor, mShimmerDuration, mIsShimmerAnim,
mAnimDuration, mPaddingOfsetRectF, mShadowColor, mShadowWidth, mBorderColor, mBorderWidth);
final ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(1, 1);
parent.addView(boriderView, lp);
return boriderView;
}
示例10: createView
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* Utility method to create the view for this router.
*
* @param parentViewGroup to inflate view with.
* @return the view for a new router.
*/
protected final ViewType createView(ViewGroup parentViewGroup) {
final Context context = parentViewGroup.getContext();
final ViewType view =
inflateView(LayoutInflater.from(onThemeContext(context)), parentViewGroup);
if (XRay.isEnabled()) {
XRay.apply(this, view);
}
return view;
}
示例11: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case VIEW_TYPE_SECTION_BREAK:
return new ViewHolder(new View(parent.getContext()));
case VIEW_TYPE_ICON:
/* falls through */
case VIEW_TYPE_PREDICTION_ICON: {
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.all_apps_icon, parent, false);
icon.setOnClickListener(mIconClickListener);
icon.setOnLongClickListener(mIconLongClickListener);
icon.setLongPressTimeout(ViewConfiguration.get(parent.getContext())
.getLongPressTimeout());
icon.setOnFocusChangeListener(mIconFocusListener);
// Ensure the all apps icon height matches the workspace icons
DeviceProfile profile = mLauncher.getDeviceProfile();
Point cellSize = profile.getCellSize();
GridLayoutManager.LayoutParams lp =
(GridLayoutManager.LayoutParams) icon.getLayoutParams();
lp.height = cellSize.y;
icon.setLayoutParams(lp);
return new ViewHolder(icon);
}
case VIEW_TYPE_EMPTY_SEARCH:
return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_empty_search,
parent, false));
case VIEW_TYPE_SEARCH_MARKET:
View searchMarketView = mLayoutInflater.inflate(R.layout.all_apps_search_market,
parent, false);
searchMarketView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLauncher.startActivitySafely(v, mMarketSearchIntent, null);
}
});
return new ViewHolder(searchMarketView);
case VIEW_TYPE_SEARCH_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_search_divider, parent, false));
case VIEW_TYPE_PREDICTION_DIVIDER:
/* falls through */
case VIEW_TYPE_SEARCH_MARKET_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_divider, parent, false));
default:
throw new RuntimeException("Unexpected view type");
}
}
示例12: buildView
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected Carousel buildView(ViewGroup parent)
{
return new Carousel(parent.getContext(), null);
}
示例13: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case ITEM_LEFT:
case ITEM_LEFT_TEXT:
Log.i("lin", "+++++lin+++++ 1");
return new LCIMChatItemTextHolder(parent.getContext(), parent, true);
case ITEM_LEFT_IMAGE:
Log.i("lin", "+++++lin+++++ 2");
return new LCIMChatItemImageHolder(parent.getContext(), parent, true);
case ITEM_LEFT_AUDIO:
Log.i("lin", "+++++lin+++++ 3");
return new LCIMChatItemAudioHolder(parent.getContext(), parent, true);
case ITEM_LEFT_LOCATION:
Log.i("lin", "+++++lin+++++ 4");
return new LCIMChatItemLocationHolder(parent.getContext(), parent, true);
case ITEM_RIGHT:
return new LCIMChatItemTextHolder(parent.getContext(), parent, false);
case ITEM_RIGHT_TEXT:
Log.i("lin", "+++++lin+++++ 5" + parent.getContext());
//Log.i("lin", "+++++lin+++++ 5" + parent);
return new LCIMChatItemTextHolder(parent.getContext(), parent, false);
case ITEM_RIGHT_IMAGE:
Log.i("lin", "+++++lin+++++ 6");
return new LCIMChatItemImageHolder(parent.getContext(), parent, false);
case ITEM_RIGHT_AUDIO:
Log.i("lin", "+++++lin+++++ 7");
return new LCIMChatItemAudioHolder(parent.getContext(), parent, false);
case ITEM_RIGHT_LOCATION:
Log.i("lin", "+++++lin+++++ 8");
return new LCIMChatItemLocationHolder(parent.getContext(), parent, false);
case TYPE_1000:
case TYPE_1001:
Log.i("lin", "---lin---> 我的类型是 1000或者是10001");
return new OrderHolder(parent.getContext(), parent, true);
default:
Log.i("lin", "+++++lin+++++ 9");
return new LCIMChatItemTextHolder(parent.getContext(), parent, true);
}
}
示例14: linkify
import android.view.ViewGroup; //导入方法依赖的package包/类
private static BetterLinkMovementExtended linkify(int linkifyMask, ViewGroup viewGroup) {
BetterLinkMovementExtended movementMethod = new BetterLinkMovementExtended(viewGroup.getContext());
rAddLinks(linkifyMask, viewGroup, movementMethod);
return movementMethod;
}
示例15: newChildView
import android.view.ViewGroup; //导入方法依赖的package包/类
protected View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup viewGroup) {
InboxMessageView entryView = new InboxMessageView(viewGroup.getContext());
initMessageView(context, entryView, this.inboxManager.getMessageFromViewCursor(cursor), isLastChild);
return entryView;
}