List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:io.intue.kamu.BestNearbyFragment.java
@Override public View newCollectionHeaderView(Context context, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); return inflater.inflate(R.layout.list_item_explore_header, parent, false); }
From source file:com.pseudosudostudios.jdd.views.Grid.java
/** * Prompts the user and calls loadGame() *//*from w ww . j a v a 2 s . co m*/ public void makeNewGame() { hasUsed = false; if (tiles != null) for (Tile[] row : tiles) for (Tile t : row) t.setVisibility(View.INVISIBLE); AlertDialog.Builder build = new AlertDialog.Builder(getContext()); build.setTitle("How many colors?").setCancelable(false); View myView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.number_colors_input, null); final EditText input = (EditText) myView.findViewById(R.id.colorInputET); final RadioButton easy = (RadioButton) myView.findViewById(R.id.easyRB); final RadioButton medium = (RadioButton) myView.findViewById(R.id.mediumRB); final RadioButton hard = (RadioButton) myView.findViewById(R.id.hardRB); build.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Grid.numberOfColors = Integer.parseInt(input.getText().toString()); if (numberOfColors < 2) { numberOfColors = 2; Toast.makeText(getContext(), getContext().getString(R.string.too_few_colors), Toast.LENGTH_SHORT).show(); } if (numberOfColors > TileFactory.colors.length) numberOfColors = TileFactory.colors.length; } catch (NumberFormatException e) { Grid.numberOfColors = 6; } if (easy.isChecked()) setDifficulty(Difficulty.EASY); if (medium.isChecked()) setDifficulty(Difficulty.MEDIUM); if (hard.isChecked()) setDifficulty(Difficulty.HARD); Tile.initPaints(); loadNewGame(); invalidate(); // let it draw! } }).setView(myView).show(); }
From source file:org.openhab.habdroid.ui.OpenHABWidgetSettingsAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /* TODO: This definitely needs some huge refactoring *///from ww w . j a v a2 s . com final int pos = position; RelativeLayout widgetView; TextView labelTextView; ImageView roomEditView; int widgetLayout = 0; OpenHABWidget openHABWidget = getItem(position); switch (this.getItemViewType(position)) { case TYPE_FRAME: widgetLayout = R.layout.openhabwidgetlist_frameitem; break; case TYPE_GROUP: widgetLayout = R.layout.openhabwidget_settings_item; break; case TYPE_IMAGE: widgetLayout = R.layout.openhabwidgetlist_imageitem; break; case TYPE_CHART: widgetLayout = R.layout.openhabwidgetlist_chartitem; break; case TYPE_VIDEO: widgetLayout = R.layout.openhabwidgetlist_videoitem; break; case TYPE_WEB: widgetLayout = R.layout.openhabwidgetlist_webitem; break; default: widgetLayout = R.layout.openhabwidget_settings_item; break; } if (convertView == null) { widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); vi.inflate(widgetLayout, widgetView, true); } else { widgetView = (RelativeLayout) convertView; } switch (getItemViewType(position)) { case TYPE_FRAME: labelTextView = (TextView) widgetView.findViewById(R.id.framelabel); if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); widgetView.setClickable(false); if (openHABWidget.getLabel().length() > 0) { // hide empty frames widgetView.setVisibility(View.VISIBLE); labelTextView.setVisibility(View.VISIBLE); } else { widgetView.setVisibility(View.GONE); labelTextView.setVisibility(View.GONE); } break; case TYPE_IMAGE: MySmartImageView imageImage = (MySmartImageView) widgetView.findViewById(R.id.imageimage); imageImage.setImageUrl(ensureAbsoluteURL(openHABBaseUrl, openHABWidget.getUrl()), false); if (openHABWidget.getRefresh() > 0) { imageImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(imageImage); } break; case TYPE_CHART: MySmartImageView chartImage = (MySmartImageView) widgetView.findViewById(R.id.chartimage); OpenHABItem chartItem = openHABWidget.getItem(); Random random = new Random(); String chartUrl = ""; if (chartItem.getType().equals("GroupItem")) { chartUrl = openHABBaseUrl + "rrdchart.png?groups=" + chartItem.getName() + "&period=" + openHABWidget.getPeriod() + "&random=" + String.valueOf(random.nextInt()); } Log.i("OpenHABWidgetAdapter", "Chart url = " + chartUrl); chartImage.setImageUrl(chartUrl, false); // TODO: This is quite dirty fix to make charts look full screen width on all displays ViewGroup.LayoutParams chartLayoutParams = chartImage.getLayoutParams(); int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); chartLayoutParams.height = (int) (screenWidth / 1.88); chartImage.setLayoutParams(chartLayoutParams); if (openHABWidget.getRefresh() > 0) { chartImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(chartImage); } Log.i("OpenHABWidgetAdapter", "chart size = " + chartLayoutParams.width + " " + chartLayoutParams.height); break; case TYPE_VIDEO: VideoView videoVideo = (VideoView) widgetView.findViewById(R.id.videovideo); Log.i("OpenHABWidgetAdapter", "Opening video at " + openHABWidget.getUrl()); // TODO: This is quite dirty fix to make video look maximum available size on all screens WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams(); videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77); videoVideo.setLayoutParams(videoLayoutParams); // We don't have any event handler to know if the VideoView is on the screen // so we manage an array of all videos to stop them when user leaves the page if (!videoWidgetList.contains(videoVideo)) videoWidgetList.add(videoVideo); // Start video if (!videoVideo.isPlaying()) { videoVideo.setVideoURI(Uri.parse(openHABWidget.getUrl())); videoVideo.start(); } Log.i("OpenHABWidgetAdapter", "Video height is " + videoVideo.getHeight()); break; case TYPE_WEB: WebView webWeb = (WebView) widgetView.findViewById(R.id.webweb); if (openHABWidget.getHeight() > 0) { ViewGroup.LayoutParams webLayoutParams = webWeb.getLayoutParams(); webLayoutParams.height = openHABWidget.getHeight() * 80; webWeb.setLayoutParams(webLayoutParams); } webWeb.setWebViewClient(new WebViewClient()); webWeb.loadUrl(openHABWidget.getUrl()); break; default: labelTextView = (TextView) widgetView.findViewById(R.id.itemlabel); roomEditView = (ImageView) widgetView.findViewById(R.id.editimg); if (null != roomEditView) { roomEditView.setVisibility(View.VISIBLE); roomEditView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (null != listItemListener) listItemListener.onEditClickListener(pos); } }); } if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); MySmartImageView sliderImage = (MySmartImageView) widgetView.findViewById(R.id.itemimage); sliderImage.setImageUrl(openHABBaseUrl + "images/" + openHABWidget.getIcon() + ".png"); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1) { if (this.getItemViewType(position + 1) == TYPE_FRAME) { dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets } else { dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others } } else { // last widget in the list, hide divider dividerLayout.setVisibility(View.GONE); } } return widgetView; }
From source file:com.ezio.multiwii.Main.MainMultiWiiActivity.java
/** Called when the activity is first created. */ @Override//from w w w . ja v a 2 s . co m public void onCreate(Bundle savedInstanceState) { app = (App) getApplication(); app.commMW.SetHandler(mHandler1); app.commFrsky.SetHandler(mHandler1); Log.d("aaa", "MAIN ON CREATE"); requestWindowFeature(Window.FEATURE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.multiwii_main_layout3); ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); adapter = new MyPagerAdapter(this); adapter.SetTitles( new String[] { getString(R.string.page1), getString(R.string.page2), getString(R.string.page3) }); final LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); adapter.AddView(inflater.inflate(R.layout.multiwii_main_layout3_1, (ViewGroup) null, false)); adapter.AddView(inflater.inflate(R.layout.multiwii_main_layout3_2, (ViewGroup) null, false)); adapter.AddView(inflater.inflate(R.layout.multiwii_main_layout3_3, (ViewGroup) null, false)); TVInfo = (TextView) adapter.views.get(0).findViewById(R.id.textViewInfoFirstPage); if (!app.FrskySupport) { ((Button) adapter.views.get(1).findViewById(R.id.buttonFrsky)).setVisibility(View.GONE); } viewPager.setAdapter(adapter); TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); titleIndicator.setViewPager(viewPager); getSupportActionBar().setDisplayShowTitleEnabled(false); app.AppStartCounter++; app.SaveSettings(true); setVolumeControlStream(AudioManager.STREAM_MUSIC); if (app.AppStartCounter == 1) startActivity(new Intent(getApplicationContext(), ConfigActivity.class)); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewWithMiniKeyboard.java
@SuppressLint("InflateParams") public void ensureMiniKeyboardInitialized() { if (mMiniKeyboard != null) return;//from www . j a va2 s . com LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); mMiniKeyboard = (AnyKeyboardViewBase) inflater.inflate(R.layout.popup_keyboard_layout, null); mMiniKeyboard.setOnKeyboardActionListener(mChildKeyboardActionListener); }
From source file:com.changhong.mscreensynergy.mainui.fragment.ViewPageFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //mInflater = inflater; View mView = inflater.inflate(R.layout.view_pager, null); showLeft = (Button) mView.findViewById(R.id.showLeft); mPager = (ViewPager) mView.findViewById(R.id.pager); PageFragment1 page1 = new PageFragment1(); PageFragment2 page2 = new PageFragment2(); PageFragment3 page3 = new PageFragment3(); // PageFragment4 page4 = new PageFragment4(); // PageFragment5 page5 = new PageFragment5(); pagerItemList.add(page1);/*from w ww .ja va 2 s. com*/ pagerItemList.add(page2); pagerItemList.add(page3); // pagerItemList.add(page4); // pagerItemList.add(page5); mAdapter = new MyAdapter(getFragmentManager()); mPager.setAdapter(mAdapter); mPager.setOffscreenPageLimit(3); //3 mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { if (myPageChangeListener != null) myPageChangeListener.onPageSelected(position); if (rg_nav_content != null && rg_nav_content.getChildCount() > position) { ((RadioButton) rg_nav_content.getChildAt(position)).performClick(); } } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int position) { } }); /* * ? */ rl_nav = (RelativeLayout) mView.findViewById(R.id.rl_nav); mHsv = (SyncHorizontalScrollView) mView.findViewById(R.id.mHsv); rg_nav_content = (RadioGroup) mView.findViewById(R.id.rg_nav_content); rg_nav_content.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (rg_nav_content.getChildAt(checkedId) != null) { TranslateAnimation animation = new TranslateAnimation(currentIndicatorLeft, ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft(), 0f, 0f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(100); animation.setFillAfter(true); //? iv_nav_indicator.startAnimation(animation); mPager.setCurrentItem(checkedId); //ViewPager ? ? //? ? ? currentIndicatorLeft = ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft(); mHsv.smoothScrollTo( (checkedId > 1 ? ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft() : 0) - ((RadioButton) rg_nav_content.getChildAt(2)).getLeft(), 0); } } }); iv_nav_indicator = (ImageView) mView.findViewById(R.id.iv_nav_indicator); iv_nav_left = (ImageView) mView.findViewById(R.id.iv_nav_left); iv_nav_right = (ImageView) mView.findViewById(R.id.iv_nav_right); LayoutParams cursor_Params = iv_nav_indicator.getLayoutParams(); cursor_Params.width = indicatorWidth;// ? iv_nav_indicator.setLayoutParams(cursor_Params); mHsv.setSomeParam(rl_nav, iv_nav_left, iv_nav_right, SlidingActivity.scontext); mInflater = (LayoutInflater) SlidingActivity.scontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); indicatorWidth = SlidingMenu.screenWidth / 4; initNavigationHSV(); return mView; }
From source file:com.mb.kids_mind.GcmIntentService.java
public void ToastAll(Context context, String msg) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_layout, null); Toast mToast = new Toast(context.getApplicationContext()); mToast.setGravity(Gravity.CENTER_VERTICAL, 0, 2); mToast.setDuration(Toast.LENGTH_SHORT); mToast.setView(layout);/*from w ww.java 2 s .c o m*/ if (flag == false) { flag = true; mToast.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { flag = false; } }, 2000);// ? ?? 2 . } else { Log.e("", " ?"); } }
From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java
/** * Generates RadioButton for each item of the {@code values} list and adds them to the * {@code radioGroup}. The item equals to {@code selectedValue} will be checked initially. Items * with special Labels can be added using {@code specialValues}. They will be added on top and * in uppercase characters./*from w ww.j a v a 2 s. co m*/ */ private <T extends Comparable> void updateRadioGroup(final RadioGroup radioGroup, List<T> values, T selectedValue, Map<T, String> specialValues) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (radioGroup == null) { return; } // Add special Values to the list List<T> specialItemsList = new ArrayList<>(specialValues.keySet()); Collections.sort(specialItemsList); for (T keys : specialItemsList) { values.add(0, keys); } radioGroup.removeAllViews(); int idCounter = 0; for (final T value : values) { View buttonLayout = inflater.inflate(R.layout.video_library_filter_radio_button, radioGroup, false); final RadioButton button = (RadioButton) buttonLayout.findViewById(R.id.button); radioGroup.addView(buttonLayout); // Set the Label of the Radio Button. TextView text = (TextView) buttonLayout.findViewById(R.id.text); text.setText(specialValues.get(value) == null ? value.toString() : specialValues.get(value)); // We have to give different IDs to all the RadioButtons inside the RadioGroup so that // only one can be checked at a time. button.setId(idCounter); idCounter++; // Trigger a RadioButton click when clicking the Text. text.setOnClickListener(new View.OnClickListener() { @Override @TargetApi(15) public void onClick(View v) { button.callOnClick(); } }); // When Clicking the RadioButton filter when re-filter the videos. button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { radioGroup.check(button.getId()); onVideoFilterChanged(value); } }); if (selectedValue.equals(value)) { radioGroup.check(button.getId()); } } }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.JustificationBySupportType.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.justification_support, container, false); Bundle b = getArguments();// ww w . ja va 2 s .c o m crt_choice = Util.ival(b.getString(POS), 0); title = b.getString("title"); body = b.getString("body"); e_title = b.getString("enhance"); Log.d(TAG, "JustificationBySupportType: ->title=" + title); // Create Expandable List and set it's properties ExpandableListView expandableList = (ExpandableListView) v .findViewById(R.id.justification_support_expandablelist); expandableList.setDividerHeight(2); expandableList.setGroupIndicator(null); expandableList.setClickable(true); expandableList.setChoiceMode(ExpandableListView.CHOICE_MODE_SINGLE); View header = getLayoutInflater(null).inflate(R.layout.justification_header, null); /*titleTextView = (WebView) header.findViewById(R.id.motion_detail_title); contentTextView = (WebView) header.findViewById(R.id.motion_detail_content); enhancingView = (WebView) header.findViewById(R.id.motion_detail_enhancing);*/ titleTextView = (TextView) header.findViewById(R.id.justification_header_title); contentTextView = (TextView) header.findViewById(R.id.justification_header_body); //titleTextView.loadData("<H1><p style=\"font-size:large;\"><b><i>"+title+"</i></b></p></H1>", "text/html", null); //titleTextView.loadData("<html><H2><i>T="+title+"</i></H2></html>", "text/html", null); titleTextView.setText(Html.fromHtml("<html><H2><i>" + title + "</i></H2></html>")); // contentTextView.loadData("<html><b>Bold?</b> <i>Italic!=</i></html>", "text/html", null);//.setText(body); //contentTextView.loadData(body, "text/html", null); contentTextView.setText(Html.fromHtml(body)); Log.d(TAG, "JustificationBySupportType: ->titletext=" + titleTextView); label_justification = (TextView) header.findViewById(R.id.label_justification); if (invalidChoice(crt_choice)) { label_justification.setText(Util.__("ALL JUSTIFICATIONS").toUpperCase()); } else { label_justification.setText(MotionDetail.crt_motion.getActualChoices()[crt_choice].name.toUpperCase()); } expandableList.addHeaderView(header); // Set the Items of Parent setGroupParents(); // Set The Child Data setChildData(); // Create the Adapter adapter = new MyExpandableAdapter(parentItems, childItems); adapter.setInflater((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE), getActivity()); // Set the Adapter to expandableList expandableList.setAdapter(adapter); /* expandableList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { return false; } });*/ return v; }
From source file:com.achep.base.ui.DialogBuilder.java
/** * Builds dialog's view//from www. java 2s . co m * * @throws IllegalArgumentException when type is not one of defined. * @see #LAYOUT_COMMON * @see #LAYOUT_SKELETON */ public View createView(int type) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup rootLayout = (ViewGroup) createSkeleton(); ViewGroup contentLayout = rootLayout; switch (type) { case LAYOUT_COMMON: final boolean hasMessageOnly = mView == null && mViewRes == 0; final int layoutResource = mContentViewRes != 0 ? mContentViewRes : hasMessageOnly ? R.layout.dialog_message : R.layout.dialog_content; ViewStub viewStub = (ViewStub) inflater.inflate(R.layout.dialog_main_body, rootLayout, true) .findViewById(R.id.placeholder); viewStub.setLayoutResource(layoutResource); contentLayout = (ViewGroup) viewStub.inflate().findViewById(R.id.content); if (contentLayout == null) contentLayout = rootLayout; TextView messageView = (TextView) contentLayout.findViewById(R.id.message); if (messageView != null) { if (!TextUtils.isEmpty(mMessageText)) { messageView.setMovementMethod(new LinkMovementMethod()); messageView.setText(mMessageText); } else { ViewGroup vg = (ViewGroup) messageView.getParent(); vg.removeView(messageView); } } // Fall down. case LAYOUT_SKELETON: if (mViewRes != 0) { inflater.inflate(mViewRes, contentLayout, true); } else if (mView != null) { contentLayout.addView(mView); } return rootLayout; default: throw new IllegalArgumentException(); } }