當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。