本文整理汇总了Java中android.view.LayoutInflater.from方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutInflater.from方法的具体用法?Java LayoutInflater.from怎么用?Java LayoutInflater.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.LayoutInflater
的用法示例。
在下文中一共展示了LayoutInflater.from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpringView
import android.view.LayoutInflater; //导入方法依赖的package包/类
public SpringView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
inflater = LayoutInflater.from(context);
mScroller = new OverScroller(context);
//获取自定义属性
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SpringView);
if (ta.hasValue(R.styleable.SpringView_type)){
int type_int = ta.getInt(R.styleable.SpringView_type, 0);
type = Type.values()[type_int];
}
if (ta.hasValue(R.styleable.SpringView_give)){
int give_int = ta.getInt(R.styleable.SpringView_give, 0);
give = Give.values()[give_int];
}
if (ta.hasValue(R.styleable.SpringView_header)){
headerResoureId = ta.getResourceId(R.styleable.SpringView_header, 0);
}
if (ta.hasValue(R.styleable.SpringView_footer)){
footerResoureId = ta.getResourceId(R.styleable.SpringView_footer, 0);
}
ta.recycle();
}
示例2: ToolBarHelper
import android.view.LayoutInflater; //导入方法依赖的package包/类
ToolBarHelper(Context context, int layoutId) {
this.mContext = context;
mInflater = LayoutInflater.from(mContext);
/*初始化整个内容*/
initContentView();
/*初始化用户定义的布局*/
initUserView(layoutId);
/*初始化toolbar*/
initToolBar();
}
示例3: onCreateViewHolder
import android.view.LayoutInflater; //导入方法依赖的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);
return viewHolder;
}
示例4: bindSupportWebParent
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
protected void bindSupportWebParent(WebParentLayout webParentLayout, Activity activity) {
super.bindSupportWebParent(webParentLayout, activity);
this.mActivity = activity;
this.mWebParentLayout = webParentLayout;
mLayoutInflater = LayoutInflater.from(mActivity);
}
示例5: EmoticonsAdapter
import android.view.LayoutInflater; //导入方法依赖的package包/类
public EmoticonsAdapter(Context context, EmoticonPageEntity emoticonPageEntity, EmoticonClickListener onEmoticonClickListener) {
this.mContext = context;
this.mInflater = LayoutInflater.from(context);
this.mEmoticonPageEntity = emoticonPageEntity;
this.mOnEmoticonClickListener = onEmoticonClickListener;
this.mItemHeightMaxRatio = DEF_HEIGHTMAXTATIO;
this.mDelbtnPosition = -1;
this.mDefalutItemHeight = this.mItemHeight = (int) context.getResources().getDimension(R.dimen.item_emoticon_size_default);
this.mData.addAll(emoticonPageEntity.getEmoticonList());
checkDelBtn(emoticonPageEntity);
}
示例6: getView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
User user = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view
ViewHolder viewHolder; // view lookup cache stored in tag
final View result;
if (convertView == null) {
viewHolder = new ViewHolder();
LayoutInflater inflater = LayoutInflater.from(getContext());
convertView = inflater.inflate(R.layout.list_search_friend, parent, false);
viewHolder.textViewSearchFriendName = (TextView) convertView.findViewById(R.id.textViewSearchFriendName);
viewHolder.textViewSearchFriendId= (TextView) convertView.findViewById(R.id.textViewSearchFriendId);
result=convertView;
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
result = convertView;
}
Animation animation = AnimationUtils.loadAnimation(mContext, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
result.startAnimation(animation);
lastPosition = position;
viewHolder.textViewSearchFriendId.setText(String.valueOf(user.getId()));
viewHolder.textViewSearchFriendName.setText(user.getFname() + " " + user.getLname());
// Return the completed view to render on screen
return convertView;
}
示例7: NewsAdapter
import android.view.LayoutInflater; //导入方法依赖的package包/类
public NewsAdapter(Context context, RealmResults<Article> articles) {
try {
this.context = context;
layoutInflater = LayoutInflater.from(context);
this.articles = articles;
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: shouldCrash_WhenDataAvailable_ForViewTypes
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Test public void shouldCrash_WhenDataAvailable_ForViewTypes() {
Activity host = buildActivity(FactsAboutNumbersActivity.class).create().get();
adapter = new FactsAdapter(LayoutInflater.from(host));
assertThat(adapter.getItemCount()).isEqualTo(0);
ThrowingCallable call = () -> adapter.getItemViewType(0);
assertThatThrownBy(call).isInstanceOf(IllegalStateException.class);
}
示例9: getCustomView
import android.view.LayoutInflater; //导入方法依赖的package包/类
public View getCustomView(final int position, View convertView,
ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
LayoutInflater layoutInflator = LayoutInflater.from(mContext);
convertView = layoutInflator.inflate(R.layout.special_materials_spinner, null);
holder = new ViewHolder();
holder.mTextView = (TextView) convertView
.findViewById(R.id.text);
holder.mCheckBox = (CheckBox) convertView
.findViewById(R.id.checkbox);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.mTextView.setText(listState.get(position).getTitle());
if (position == 0) {
holder.mCheckBox.setVisibility(View.VISIBLE);
} else {
holder.mCheckBox.setVisibility(View.VISIBLE);
}
holder.mCheckBox.setTag(position);
holder.mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//If box is clicked, set it to true;
int getPosition = (Integer) buttonView.getTag();
if (isChecked){
listState.get(getPosition).setSelected(true);
}
else{
listState.get(getPosition).setSelected(false);
}
}
});
return convertView;
}
示例10: HomeRecycleAdapter
import android.view.LayoutInflater; //导入方法依赖的package包/类
public HomeRecycleAdapter(Context mContext, ResultBean resultBean) {
this.mContext = mContext;
this.resultBean = resultBean;
mLayoutInflater = LayoutInflater.from(mContext);
}
示例11: onCreateViewHolder
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public OrderItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View view = layoutInflater.inflate(R.layout.order_dish_item, parent, false);
return new OrderItemHolder(view);
}
示例12: initialize
import android.view.LayoutInflater; //导入方法依赖的package包/类
private void initialize() {
inflator = LayoutInflater.from(upnpClient.getContext());
players = upnpClient.getCurrentPlayers();
}
示例13: LaunchpadAdapter
import android.view.LayoutInflater; //导入方法依赖的package包/类
public LaunchpadAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
示例14: onCreateViewHolder
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater=LayoutInflater.from(parent.getContext());
View view=inflater.inflate(R.layout.bar_search_anchor,parent,false);
return new ViewHolder(view);
}
示例15: onCreateViewHolder
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public final VH onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
return onCreateViewHolder(inflater, parent, viewType);
}