Java Code Examples for android.view.View.inflate()

The following are Jave code examples for showing how to use inflate() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AndroidPicker   File: AddressPicker.java   View Source Code Vote up 8 votes
public AddressPicker(Context context) {
    super(context, R.style.transparentWindowStyle);

    this.context = context;
    view=View.inflate(context,R.layout.layout_address_picker,null);

    initCityData();

    initView();
    initData();
    setListener();
    this.setContentView(view);

    this.setCanceledOnTouchOutside(true);

    //从底部弹出
    Window window = this.getWindow();
    window.setGravity(Gravity.BOTTOM);  //此处可以设置dialog显示的位置
    window.setWindowAnimations(R.style.windowAnimationStyle);  //添加动画

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(params);
}
 
Example 2
Project: ClouldReader   File: CustomFragment.java   View Source Code Vote up 7 votes
/**
 * 设置adapter
 */
private void setAdapter(GankIoDataBean mCustomBean) {
    if (mHeaderView == null) {
        mHeaderView = View.inflate(getContext(), R.layout.header_item_gank_custom, null);
        bindingView.xrvCustom.addHeaderView(mHeaderView);
    }
    initHeader(mHeaderView);

    boolean isAll = SPUtils.getString("gank_cala", "全部").equals("全部");
    mAndroidAdapter.clear();
    mAndroidAdapter.setAllType(isAll);
    mAndroidAdapter.addAll(mCustomBean.getResults());
    bindingView.xrvCustom.setLayoutManager(new LinearLayoutManager(getActivity()));
    bindingView.xrvCustom.setAdapter(mAndroidAdapter);
    mAndroidAdapter.notifyDataSetChanged();

    mIsFirst = false;
}
 
Example 3
Project: Bailan   File: SubTabNavigator.java   View Source Code Vote up 7 votes
private void addTextView(Context context, int viewTag) {
    TextView tv = (TextView) View.inflate(context, R.layout.custom_textview, null);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.weight = 1.0F;

    tv.setLayoutParams(layoutParams);
    tv.setOnClickListener(this);
    tv.setGravity(Gravity.CENTER);
    if (mTextSize > 0f)
        tv.setTextSize(0, mTextSize);

    tv.setOnClickListener(this);
    tv.setTag(viewTag);
    if (viewTag == TAG_LEFT_VIEW) {
        tv.setText(mLeftText);
        mLeftTextView = tv;
    } else if (viewTag == TAG_NONE_VIEW) {
        tv.setText(mSimpleText);
        mSimpleTextView = tv;
    } else if (viewTag == TAG_RIGHT_VIEW) {
        tv.setText(mRightText);
        mRightTextView = tv;
    }
    addView(tv);
}
 
Example 4
Project: CXJPadProject   File: TwentyTestFragment.java   View Source Code Vote up 7 votes
@Override
protected View initRootView(LayoutInflater inflater) {
    if (view == null) {
        view = View.inflate(getActivity(), R.layout.scroll, null);
    }
    ButterKnife.bind(this, view);
    ViewGroup myparent = (ViewGroup) view.getParent();
    //获取args传递的参数
    if (getArguments() != null) {
        orderid = getArguments().getString("orderId");
    }
    if (myparent != null) {
        myparent.removeView(view);
    }
    return view;
}
 
Example 5
Project: GitHub   File: Buildable.java   View Source Code Vote up 7 votes
protected BuildBean buildLoading(BuildBean bean) {
    Dialog dialog = new Dialog(bean.mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    bean.dialog = dialog;
    View root;
    if (bean.isVertical) {
        root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
    } else {
        root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
    }
    View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
    ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
    TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
    tvMsg.setText(bean.msg);
    if (bean.isWhiteBg) {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
        tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
    } else {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
        tvMsg.setTextColor(Color.WHITE);
    }
    bean.dialog.setContentView(root);
    return bean;
}
 
Example 6
Project: MobileMedia   File: SearchAdapter.java   View Source Code Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHoder viewHoder;
    if(convertView ==null){
        convertView = View.inflate(context, R.layout.net_video_item,null);
        viewHoder = new ViewHoder();
        viewHoder.iv_icon = (ImageView) convertView.findViewById(R.id.net_video_img);
        viewHoder.tv_name = (TextView) convertView.findViewById(R.id.net_video_name);
        viewHoder.tv_desc = (TextView) convertView.findViewById(R.id.net_video_desc);

        convertView.setTag(viewHoder);
    }else{
        viewHoder = (ViewHoder) convertView.getTag();
    }
    SearchBean.ItemData mediaItem = mediaItems.get(position);
    viewHoder.tv_name.setText(mediaItem.getItemTitle());
    viewHoder.tv_desc.setText(mediaItem.getKeywords());
    Glide.with(context).load(mediaItem.getItemImage().getImgUrl1())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .placeholder(R.drawable.video_default)
            .error(R.drawable.video_default)
            .into(viewHoder.iv_icon);
    return convertView;
}
 
Example 7
Project: EditorImageAndText   File: ImageGridActivity.java   View Source Code Vote up 7 votes
protected void initView() {
    gridView = (GridView) findViewById(R.id.gridview);
    photo_delete = (ImageView) findViewById(R.id.photo_delete);
    photo_choose = (ImageView) findViewById(R.id.photo_choose);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    if (type == VIDEOTYPE) {
        adapter = new ImageGridAdapter(ImageGridActivity.this, null, videoList,
                mHandler, type);
    } else {
        adapter = new ImageGridAdapter(ImageGridActivity.this, dataList, null,
                mHandler, type);
    }
    dialog = new Dialog(this);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setTitle("数据上传");
    View view = View.inflate(this, R.layout.customerdialogcheckroll, null);
    bar = (ProgressBar) view.findViewById(R.id.customerdialog_pb);
    tip = (TextView) view.findViewById(R.id.customerdialog_tv);

    dialog.setContentView(view);
    gridView.setAdapter(adapter);
}
 
Example 8
Project: 12306_Android   File: MainActivity.java   View Source Code Vote up 7 votes
private void buildChoosePassengersDialog() {
    List<Passenger> passengers = PassengerUtil.getPassengers();
    final List<String> list = new ArrayList<>();
    for (Passenger p : passengers) {
        list.add(p.getPassenger_name());
    }

    View view = View.inflate(MainActivity.this, R.layout.choose_passengers, null);
    ListView listView = (ListView) view.findViewById(R.id.list_view);
    PassengersAdapter adapter = new PassengersAdapter(MainActivity.this, list);
    listView.setAdapter(adapter);

    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle("选择乘车人");
    builder.setView(view);
    AlertDialogUtil.setButton(builder, adapter, choosePassengers);
    builder.show();
}
 
Example 9
Project: CXJPadProject   File: TransferFragment.java   View Source Code Vote up 7 votes
@Override
protected View initRootView(LayoutInflater inflater) {
    if (view == null) {
        view = View.inflate(getActivity(), R.layout.fragment_order_tranfer, null);
    }
    unbinder = ButterKnife.bind(this, view);
    ViewGroup myparent = (ViewGroup) view.getParent();
    if (getArguments() != null) {
        argsModel = (ShowTransferStoreReqModel) getArguments().getSerializable("args");
        transferCallback = (ResultCallback<TransfersTempModel>) getArguments().getSerializable("transferCallback");
    }
    if (myparent != null) {
        myparent.removeView(view);
    }
    return view;
}
 
Example 10
Project: Hotspot-master-devp   File: SearchView.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View view = null;
	ViewHolder viewHolder = null;
	if(convertView!=null) {
		view = convertView;
		viewHolder = (ViewHolder) view.getTag();
	}else {
		viewHolder = new ViewHolder();
		view = View.inflate(mContext, R.layout.search_result_item, null);
		viewHolder.contentText = (TextView) view.findViewById(R.id.tv_content);
		view.setTag(viewHolder);
	}
	String content = mResults.get(position).getName();
	viewHolder.contentText.setText(content);
	return view;
}
 
Example 11
Project: SubwayTooter   File: ColorPaletteAdapter.java   View Source Code Vote up 6 votes
ViewHolder(Context context) {
  int layoutResId;
  if (colorShape == ColorShape.SQUARE) {
    layoutResId = R.layout.cpv_color_item_square;
  } else {
    layoutResId = R.layout.cpv_color_item_circle;
  }
  view = View.inflate(context, layoutResId, null);
  colorPanelView = (ColorPanelView) view.findViewById(R.id.cpv_color_panel_view);
  imageView = (ImageView) view.findViewById(R.id.cpv_color_image_view);
  originalBorderColor = colorPanelView.getBorderColor();
  view.setTag(this);
}
 
Example 12
Project: FlycoTabLayout   File: SlidingTabLayout.java   View Source Code Vote up 6 votes
/** 更新数据 */
public void notifyDataSetChanged() {
    mTabsContainer.removeAllViews();
    this.mTabCount = mTitles == null ? mViewPager.getAdapter().getCount() : mTitles.size();
    View tabView;
    for (int i = 0; i < mTabCount; i++) {
        tabView = View.inflate(mContext, R.layout.layout_tab, null);
        CharSequence pageTitle = mTitles == null ? mViewPager.getAdapter().getPageTitle(i) : mTitles.get(i);
        addTab(i, pageTitle.toString(), tabView);
    }

    updateTabStyles();
}
 
Example 13
Project: GitHub   File: ToastUtil.java   View Source Code Vote up 6 votes
public Toast createShort() {
    View contentView = View.inflate(context, R.layout.dialog_toast, null);
    TextView tvMsg = (TextView) contentView.findViewById(R.id.tv_toast_msg);
    toast = new Toast(context);
    toast.setView(contentView);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    tvMsg.setText(msg);
    return toast;
}
 
Example 14
Project: XinFramework   File: ToastPrompt.java   View Source Code Vote up 6 votes
/**
 * 显示警告的Toast
 *
 * @param text String
 */
public static void showWarnToast(Context context, String text) {
    View view = View.inflate(context, R.layout.toast_view_prompt, null);
    TextView tv = (TextView) view.findViewById(R.id.tv_toast_prompt);
    tv.setText(text);
    tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.toast_show_warn, 0, 0, 0);

    Toast toast = getToast(context, view);
    toast.show();
}
 
Example 15
Project: GitHub   File: BGAMeiTuanRefreshViewHolder.java   View Source Code Vote up 6 votes
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_meituan, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }

        mMeiTuanRefreshView = (BGAMeiTuanRefreshView) mRefreshHeaderView.findViewById(R.id.meiTuanView);
        if (mPullDownImageResId != -1) {
            mMeiTuanRefreshView.setPullDownImageResource(mPullDownImageResId);
        } else {
            throw new RuntimeException("请调用" + BGAMeiTuanRefreshViewHolder.class.getSimpleName() + "的setPullDownImageResource方法设置下拉过程中的图片资源");
        }
        if (mChangeToReleaseRefreshAnimResId != -1) {
            mMeiTuanRefreshView.setChangeToReleaseRefreshAnimResId(mChangeToReleaseRefreshAnimResId);
        } else {
            throw new RuntimeException("请调用" + BGAMeiTuanRefreshViewHolder.class.getSimpleName() + "的setChangeToReleaseRefreshAnimResId方法设置进入释放刷新状态时的动画资源");
        }
        if (mRefreshingAnimResId != -1) {
            mMeiTuanRefreshView.setRefreshingAnimResId(mRefreshingAnimResId);
        } else {
            throw new RuntimeException("请调用" + BGAMeiTuanRefreshViewHolder.class.getSimpleName() + "的setRefreshingAnimResId方法设置正在刷新时的动画资源");
        }
    }
    return mRefreshHeaderView;
}
 
Example 16
Project: IndicatorSeekBar   File: Indicator.java   View Source Code Vote up 6 votes
/**
 * set the  View to the indicator top container, not influence indicator arrow ;
 * if indicator type is custom , this method will be not work.
 *
 * @param topContentLayoutId the view id for indicator TOP part, not influence indicator arrow;
 */
public void setIndicatorTopContentLayout(@LayoutRes int topContentLayoutId) {
    mTopContentView.removeAllViews();
    View topContentView = View.inflate(mContext, topContentLayoutId, null);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        topContentView.setBackground(getGradientDrawable());
    } else {
        topContentView.setBackgroundDrawable(getGradientDrawable());
    }
    mTopContentView.addView(topContentView);
}
 
Example 17
Project: OpenYOLO-Android   File: AuthenticationMethodsInputView.java   View Source Code Vote up 5 votes
private void initialize(Context context) {
    View view = View.inflate(context, R.layout.authentication_method_input_layout, this);

    ButterKnife.bind(view);
}
 
Example 18
Project: NanoIconPack   File: ReqMenuDialog.java   View Source Code Vote up 5 votes
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    Bundle bundle = getArguments();
    pos = bundle.getInt("pos");
    bean = (AppBean) bundle.getSerializable("bean");

    contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null);
    dialog.setContentView(contentView);

    ((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel());
    if (bean.isMark()) {
        contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_undo_mark)
                .setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE);
    } else {
        contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_mark)
                .setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE);
    }
    contentView.findViewById(R.id.view_hint_lost)
            .setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE);
    contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this);
    contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this);

    BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior
            .from((View) contentView.getParent());
    if (bean.isHintLost()) {
        // In landscape, STATE_EXPANDED doesn't make sheet expanded.
        // Maybe it's a bug. So do this to fix it.
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            contentView.measure(0, 0);
            bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
        }
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
        bottomSheetBehavior.setPeekHeight(getResources()
                .getDimensionPixelSize(R.dimen.req_bottom_menu_height));
    }
}
 
Example 19
Project: music-player   File: FileItemView.java   View Source Code Vote up 5 votes
public FileItemView(Context context) {
    super(context);
    View.inflate(context, R.layout.item_local_file, this);
    ButterKnife.bind(this);
}
 
Example 20
Project: GitHub   File: SuperLvHolder.java   View Source Code Vote up 5 votes
public SuperLvHolder(Context context){
    rootView = View.inflate(context,setLayoutRes(),null);
    //ButterKnife.bind(this,rootView);
}