List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:arun.com.chromer.webheads.ui.views.BaseWebHead.java
private void inflateContent(@NonNull Context context) { // size/*w w w .java2 s . c o m*/ if (Preferences.get(context).webHeadsSize() == 2) { contentRoot = (FrameLayout) LayoutInflater.from(getContext()) .inflate(R.layout.widget_web_head_layout_small, this, false); } else contentRoot = (FrameLayout) LayoutInflater.from(getContext()).inflate(R.layout.widget_web_head_layout, this, false); addView(contentRoot); ButterKnife.bind(this); webHeadColor = Preferences.get(context).webHeadColor(); indicator.setText(Utils.getFirstLetter(url)); indicator.setTextColor(getForegroundWhiteOrBlack(webHeadColor)); initRevealView(webHeadColor); if (badgeDrawable == null) { badgeDrawable = new BadgeDrawable.Builder().type(TYPE_NUMBER) .badgeColor(ContextCompat.getColor(getContext(), R.color.accent)).textColor(WHITE) .number(WEB_HEAD_COUNT).build(); } else { badgeDrawable.setNumber(WEB_HEAD_COUNT); } badgeView.setVisibility(VISIBLE); badgeView.setText(new SpannableString(badgeDrawable.toSpannable())); updateBadgeColors(webHeadColor); if (!Utils.isLollipopAbove()) { final int pad = dpToPx(5); badgeView.setPadding(pad, pad, pad, pad); } }
From source file:ar.uba.fi.splitapp.ChatSessionActivity.java
private void addResponse(int layoutId, String username, String userId, String message) { LayoutInflater inflater = LayoutInflater.from(this); View layout = inflater.inflate(layoutId, null); CircularImageView imageView = (CircularImageView) layout.findViewById(R.id.chat_user_img); FacebookManager.fillWithUserPic(userId, imageView, getApplicationContext()); TextView nameTextView = (TextView) layout.findViewById(R.id.chat_user_name); nameTextView.setText(username + ":"); TextView msgTextView = (TextView) layout.findViewById(R.id.chat_user_msg); msgTextView.setText(message);/*from w w w. j a va 2 s . c om*/ runOnUiThread(() -> mMessagesLayout.addView(layout)); runOnUiThread(this::scrollToLast); }
From source file:benefits.with.school.hackaton.tabsactivity.lib.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;// 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; } 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); } tabTitleView.setTextColor(getResources().getColorStateList(android.R.color.white)); tabTitleView.setTextSize(14); } }
From source file:android.example.ui.widget.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;//w ww . 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; } 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:ariana.myapplication.iosched.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 ww w . j a va 2 s. co 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:br.com.carlos.ceciliaapp.slidingtabs.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;/* w w w . ja v a 2s . co 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)); 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); } tabTitleView.setTextColor(Color.parseColor("#ffffff")); } }
From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java
public static <D extends FhemDevice<D>> TypeHandler<D> handlerForSelectedOption(D device, Context context, final String option, final TargetStateSelectedCallback callback) { SetList setList = device.getSetList(); final SetListValue setListValue = setList.get(option); final DeviceStateRequiringAdditionalInformation specialDeviceState = DeviceStateRequiringAdditionalInformation .deviceStateForFHEM(option); if (setListValue instanceof SetListSliderValue) { final SetListSliderValue sliderValue = (SetListSliderValue) setListValue; return new TypeHandler<D>() { private int dimProgress = 0; @Override/*from w ww .j a va2s . c o m*/ public View getContentViewFor(Context context, D device) { TableLayout tableLayout = new TableLayout(context); int initialProgress = 0; if (device instanceof DimmableDevice) { initialProgress = ((DimmableDevice) device).getDimPosition(); } tableLayout.addView(new DeviceDimActionRowFullWidth<D>(initialProgress, sliderValue.getStart(), sliderValue.getStep(), sliderValue.getStop(), null, R.layout.device_detail_seekbarrow_full_width) { @Override public void onStopDim(Context context, D device, int progress) { dimProgress = progress; } @Override public String toDimUpdateText(D device, int progress) { return null; } }.createRow(LayoutInflater.from(context), device)); return tableLayout; } @Override public boolean onPositiveButtonClick(View view, Context context, D device) { callback.onTargetStateSelected(option, "" + dimProgress, device, context); return true; } }; } else if (setListValue instanceof SetListGroupValue) { final SetListGroupValue groupValue = (SetListGroupValue) setListValue; final List<String> groupStates = groupValue.getGroupStates(); return new TypeHandler<D>() { @Override public View getContentViewFor(final Context context, final D device) { ListView listView = new ListView(context); listView.setAdapter( new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, groupStates)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { String selection = groupStates.get(position); callback.onTargetStateSelected(option, selection, device, context); dialog.dismiss(); } }); return listView; } @Override boolean requiresPositiveButton() { return false; } }; } else if (specialDeviceState != null) { return new TypeHandler<D>() { private EditText editText; @Override public View getContentViewFor(Context context, D device) { editText = new EditText(context); return editText; } @Override public boolean onPositiveButtonClick(View view, Context context, D device) { Editable value = editText.getText(); String text = value == null ? "" : value.toString(); if (isValidAdditionalInformationValue(text, specialDeviceState)) { callback.onTargetStateSelected(option, text, device, context); return true; } else { DialogUtil.showAlertDialog(context, R.string.error, R.string.invalidInput); return false; } } }; } else { callback.onTargetStateSelected(option, null, device, context); return null; } }
From source file:at.linuxtage.companion.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;/*from ww w. j a v a 2 s . c om*/ TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { setSelectedCompat(tabView, true); } } }
From source file:app.rasendriya.cintamasjid.service.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. ja 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); 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)); 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); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); } }
From source file:boletimescolar.info.boletimelavamosnos.view.tabs.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;/*www . j a v a2s . 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); 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)); 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); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.tab_selector)); tabTitleView.setTextSize(14); } }