List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:reportsas.com.formulapp.Formulario.java
public void addPreguntas(Pregunta pregunta) { LayoutInflater inflater = LayoutInflater.from(this); LinearLayout relativeLayout = obtenerLayout(inflater, pregunta); layout.addView(relativeLayout);/*from w ww . j a v a 2s . c o m*/ }
From source file:android.kectech.com.stylingactionbar.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w w w .j a v a 2 s . c om TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); // added by paul if (mTabViewTextViewId > 0) tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } // added by paul if (tabTitleView != null) { tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(getResources().getColorStateList(R.drawable.text_tab)); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:attendance.student.prjstudentattendancerecord.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from www . j a v a 2 s. com*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } assert tabTitleView != null; tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:alexander.martinz.libs.materialpreferences.MaterialPreference.java
public LayoutInflater getLayoutInflater() { LayoutInflater inflater = getCustomLayoutInflater(); if (inflater == null) { inflater = LayoutInflater.from(getContext()); }/*from ww w . j ava 2s . c o m*/ return inflater; }
From source file:android.support.v7.internal.widget.ActivityChooserView.java
/** * Create a new instance./*from www .j a va 2 s.c om*/ * * @param context The application environment. * @param attrs A collection of attributes. * @param defStyle The default style to apply to this view. */ public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView, defStyle, 0); mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable); attributesArray.recycle(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.abc_activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image); final FrameLayout expandButton = (FrameLayout) findViewById(R.id.expand_activities_button); expandButton.setOnClickListener(mCallbacks); expandButton.setOnTouchListener(new ListPopupWindow.ForwardingListener(expandButton) { @Override public ListPopupWindow getPopup() { return getListPopupWindow(); } @Override protected boolean onForwardingStarted() { showPopup(); return true; } @Override protected boolean onForwardingStopped() { dismissPopup(); return true; } }); mExpandActivityOverflowButton = expandButton; mExpandActivityOverflowButtonImage = (ImageView) expandButton.findViewById(R.id.image); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); mAdapter = new ActivityChooserViewAdapter(); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); updateAppearance(); } }); Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); }
From source file:com.df.kia.procedures.CarRecogniseLayout.java
private void init(final Context context) { rootView = LayoutInflater.from(context).inflate(R.layout.car_recognise_layout, this); deleteLastLicensePhoto();/* w w w . ja va 2 s . c o m*/ mCarSettings = InputProceduresLayout.mCarSettings; licenseRecognise = new LicenseRecognise(context, AppCommon.licensePhotoPath); licenseImageView = (ImageView) findViewById(R.id.licenseImage); licenseImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { licenseRecognise.takePhoto(mHandler); } }); // recogniseButton = (Button) rootView.findViewById(R.id.recognise_button); recogniseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // ??? if (!mCarSettings.getBrandString().equals("")) { reRecognise(R.string.reRecognise1); } else if (!getEditViewText(rootView, R.id.plateNumber_edit).equals("")) { reRecognise(R.string.reRecognise); } else { //fillInDummyData(); if (licensePhotoExist()) recogniseLicense(); else Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } } }); // vin Button vinConfirmButton = (Button) rootView.findViewById(R.id.vinConfirm_button); vinConfirmButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // VIN?? if (getEditViewText(rootView, R.id.vin_edit).equals("")) { Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show(); } else { checkVinAndGetCarSettings(); } } }); // ? Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button); brandSelectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { selectCarManually(); } }); vehicleTypeEdit = (EditText) rootView.findViewById(R.id.vehicleType_edit); vehicleTypeEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.vehicleType_items, R.id.vehicleType_edit); break; } return false; } }); useCharacterEdit = (EditText) rootView.findViewById(R.id.useCharacter_edit); useCharacterEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.useCharacter_items, R.id.useCharacter_edit); break; } return false; } }); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; EditText vin_edit = (EditText) findViewById(R.id.vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); EditText plateNumberEdit = (EditText) findViewById(R.id.plateNumber_edit); plateNumberEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); EditText licenseModelEdit = (EditText) findViewById(R.id.licenseModel_edit); licenseModelEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(22) }); EditText engineSerialEdit = (EditText) findViewById(R.id.engineSerial_edit); engineSerialEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); vehicleModel = MainActivity.vehicleModel; }
From source file:beer.dku.com.beerprototype.material.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w.j av a 2 s .c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(Color.WHITE); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:app.sunstreak.yourpisd.googleutil.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w w w . j a va 2 s . c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (!useCustom) tabTitleView.setText(adapter.getPageTitle(i)); else { tabTitleView.setText(titleArray.get(i)); } tabTitleView.setTextColor(getResources().getColor(R.color.white)); //added by @Han for yourpisd tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java
@Nullable @Override/*from ww w .ja v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate(getResourceLayout(), container, false); onLoadView(view); return view; }
From source file:net.evecom.androidecssp.activity.taskresponse.TaskAndResponsesInfoActivity.java
/** * /*from ww w .jav a 2s. c om*/ * * * @author Mars zhang * @created 2015-12-29 7:52:06 */ private void loadResponses() { responseLayout.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(instance); for (int i = 0; i < taskResponseInfos.size(); i++) { final BaseModel baseModel = taskResponseInfos.get(i); View view = inflater.inflate(R.layout.task_response_response_item, null, true); responseLayout.addView(view); // LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams( // LinearLayout.LayoutParams.WRAP_CONTENT, // LinearLayout.LayoutParams.WRAP_CONTENT); // lp.setMargins(0, 0, 0, 10); // view.setLayoutParams(lp); TextView dept = (TextView) view.findViewById(R.id.task_response_info_response_dept); TextView createtime = (TextView) view.findViewById(R.id.task_response_info_response_createtime); TextView name = (TextView) view.findViewById(R.id.task_response_info_response_name); TextView context = (TextView) view.findViewById(R.id.task_response_info_response_content); LinearLayout layout = (LinearLayout) view.findViewById(R.id.task_response_info_response_imagely); dept.setText(ifnull(baseModel.get("name"), "")); createtime.setText(ifnull(baseModel.get("createtime"), "")); name.setText(ifnull(baseModel.get("responsetitle"), "")); context.setText(ifnull(baseModel.get("responsecon"), "")); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), TaskResponseInfoActivity.class); pushData("responseinfo", baseModel, intent); startActivity(intent); } }); String imageids = ifnull(baseModel.get("detailattach"), ""); if (imageids.length() > 0) { String[] imagesplits = imageids.split(","); for (int j = 0; j < imagesplits.length && j < 6; j++) { View imgview = inflater.inflate(R.layout.task_response_response_item_image, null, true); layout.addView(imgview); // LinearLayout.LayoutParams imagelp=new // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, // LinearLayout.LayoutParams.WRAP_CONTENT); // lp.setMargins(2, 2, 2, 2); // imgview.setLayoutParams(imagelp); ImageView imageView = (ImageView) imgview.findViewById(R.id.task_response_rsponse_item_iamge); HashMap<String, String> mparas = new HashMap<String, String>(); mparas.put("fileid", imagesplits[j]); displayImageWithWidthHeight(imageView, HttpUtil.getPCURL() + "jfs/ecssp/mobile/pubCtr/getImageFlowById", mparas, 60, 60); } } } }