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


Java LayoutInflater.from方法代码示例

本文整理汇总了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();
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:26,代码来源:SpringView.java

示例2: ToolBarHelper

import android.view.LayoutInflater; //导入方法依赖的package包/类
ToolBarHelper(Context context, int layoutId) {
    this.mContext = context;
    mInflater = LayoutInflater.from(mContext);
    /*初始化整个内容*/
    initContentView();
    /*初始化用户定义的布局*/
    initUserView(layoutId);
    /*初始化toolbar*/
    initToolBar();
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:11,代码来源:ToolBarHelper.java

示例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;
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:25,代码来源:GreenAdapter.java

示例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);
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:8,代码来源:DefaultDesignUIController.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:EmoticonsAdapter.java

示例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;
}
 
开发者ID:Amay-Mishra,项目名称:Trackr,代码行数:36,代码来源:SearchFriendListAdapter.java

示例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();
    }


}
 
开发者ID:nyangate,项目名称:Crypto-Assistant,代码行数:12,代码来源:NewsAdapter.java

示例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);
}
 
开发者ID:ubiratansoares,项目名称:reactive-architectures-playground,代码行数:10,代码来源:FactsAdapterTests.java

示例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;
}
 
开发者ID:TranAlan,项目名称:Chore-Manager-App,代码行数:45,代码来源:CustomMaterialListAdapter.java

示例10: HomeRecycleAdapter

import android.view.LayoutInflater; //导入方法依赖的package包/类
public HomeRecycleAdapter(Context mContext, ResultBean resultBean) {
    this.mContext = mContext;
    this.resultBean = resultBean;
    mLayoutInflater = LayoutInflater.from(mContext);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:HomeRecycleAdapter.java

示例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);
}
 
开发者ID:Wisebite,项目名称:wisebite_android,代码行数:7,代码来源:OrderItemAdapter.java

示例12: initialize

import android.view.LayoutInflater; //导入方法依赖的package包/类
private void initialize() {
    inflator = LayoutInflater.from(upnpClient.getContext());
    players = upnpClient.getCurrentPlayers();

}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:6,代码来源:PlayerListItemAdapter.java

示例13: LaunchpadAdapter

import android.view.LayoutInflater; //导入方法依赖的package包/类
public LaunchpadAdapter(Context context) {
    mInflater = LayoutInflater.from(context);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:4,代码来源:LaunchpadAdapter.java

示例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);
}
 
开发者ID:toonine,项目名称:BalaFM,代码行数:7,代码来源:SearchResultAnchor.java

示例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);
}
 
开发者ID:GlobusLTD,项目名称:recyclerview-android,代码行数:6,代码来源:Adapter.java


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