List of usage examples for android.view LayoutInflater inflate
public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot)
From source file:Main.java
public static View chargerLayout(LayoutInflater inflater, ViewGroup container, int layout) { if (container == null) { return null; }// w w w. ja v a 2 s . c o m LinearLayout linearLayout = (LinearLayout) inflater.inflate(layout, container, false); return linearLayout; }
From source file:Main.java
public static <T extends View> T inflateWithOutOfMemoryRetrial(Class<T> clazz, LayoutInflater inflater, int resourceId, ViewGroup root, boolean attachToRoot) { for (int i = 0; i < OUT_OF_MEMORY_RETRY_COUNT; ++i) { try {//from w w w. ja v a 2s . c o m return clazz.cast(inflater.inflate(resourceId, root, attachToRoot)); } catch (OutOfMemoryError e) { // Retry with GC. System.gc(); } } return clazz.cast(inflater.inflate(resourceId, root, attachToRoot)); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
@SuppressLint("NewApi") private static View createMessageDialogContentsView(Activity activity, MessageDescription messageDescription) { Context context = activity;//from w w w. j ava2s . c o m final AlertDialog.Builder builder; // Workaround for dialog theme problems if (android.os.Build.VERSION.SDK_INT > 10) { builder = new AlertDialog.Builder(context); context = builder.getContext(); } else { context = new ContextThemeWrapper(context, android.R.style.Theme_Dialog); builder = new AlertDialog.Builder(context); } builder.setTitle("Send feedback"); final LayoutInflater inflater = LayoutInflater.from(context); final View dialogContentsView = inflater.inflate(R.layout.updater_dialog_message, null, false); final TextView textView = (TextView) dialogContentsView.findViewById(R.id.dialog_update_message_text); final ImageView imageView = (ImageView) dialogContentsView.findViewById(R.id.dialog_update_message_image); final ViewSwitcher switcher = (ViewSwitcher) dialogContentsView .findViewById(R.id.dialog_update_message_switcher); String messageText = null; String imageUrl = null; if (messageDescription != null) { messageText = messageDescription.get(MessageDescription.KEY_MESSAGE); imageUrl = messageDescription.get(MessageDescription.KEY_IMAGE_URL); } if (Utilities.isNullOrEmpty(messageText)) { textView.setVisibility(View.GONE); } else { textView.setText(messageText); } if (Utilities.isNullOrEmpty(imageUrl)) { switcher.setVisibility(View.GONE); } else { URI uri; try { uri = new URI(imageUrl); } catch (URISyntaxException e) { uri = null; } if (uri != null) { DownloadRequest request = new DownloadRequest(); request.setUri(uri); request.setDownloadHandler(new DownloadHandler() { @Override public void onSuccess(byte[] result) { // Load image from byte array final Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length); imageView.setImageBitmap(bitmap); // Hide progress bar and display image if (switcher != null) { switcher.setDisplayedChild(1); } } @Override public void onProgress(Integer percent) { } @Override public void onFail(Exception ex) { Log.e("Message image couldn't be loaded", ex); } @Override public void onCancelled() { } }); HttpClient client = Utilities.createClient("Turkcell Updater/1.0 ", false); try { request.executeAsync(client); } catch (Exception e) { Log.e("Message image couldn't be loaded", e); } } else { switcher.setVisibility(View.GONE); } } return dialogContentsView; }
From source file:DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_detail, container, false); }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static View inflateName(Context context, String name, ViewGroup parent) { if (name.startsWith("<")) { // Assume it's XML return DynamicLayoutInflator.inflate(context, name, parent); } else {//from w ww . ja v a 2 s . c o m File savedFile = context.getFileStreamPath(name + ".xml"); try { InputStream fileStream = new FileInputStream(savedFile); return DynamicLayoutInflator.inflate(context, fileStream, parent); } catch (FileNotFoundException e) { } try { InputStream assetStream = context.getAssets().open(name + ".xml"); return DynamicLayoutInflator.inflate(context, assetStream, parent); } catch (IOException e) { } int id = context.getResources().getIdentifier(name, "layout", context.getPackageName()); if (id > 0) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); return inflater.inflate(id, parent, false); } } return null; }
From source file:SlideFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_slide, container, false); ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView); imageView.setImageResource(mImageResourceID); return rootView; }
From source file:com.example.kyle.weatherforecast.WeatherFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_layout, container, false); Bundle args = getArguments();/* w w w . j a v a 2 s . c o m*/ int i = args.getInt("day"); TextView textOutlook = ((TextView) rootView.findViewById(R.id.text_outlook)); ImageView symbolView = ((ImageView) rootView.findViewById(R.id.image_symbol)); TextView tempsView = ((TextView) rootView.findViewById(R.id.text_temp)); TextView windView = ((TextView) rootView.findViewById(R.id.text_min)); TextView realFeelView = ((TextView) rootView.findViewById(R.id.text_real_feel)); textOutlook.setText(WeatherData.outlookArray[i]); symbolView.setImageResource(WeatherData.symbolArray[i]); tempsView.setText(WeatherData.tempsArray[i] + "c"); windView.setText(("Min " + WeatherData.minArray[i] + "c")); realFeelView.setText("Real feel " + WeatherData.realFeelArray[i] + "c"); return rootView; }
From source file:com.manning.androidhacks.hack030.view.CountryView.java
public CountryView(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.country_view, this, true); mTitle = (TextView) v.findViewById(R.id.country_view_title); mCheckBox = (CheckBox) v.findViewById(R.id.country_view_checkbox); }
From source file:com.aqnote.app.wifianalyzer.wifi.ChannelAvailableAdapter.java
@NonNull @Override//from w w w . j a v a 2s .c om public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater layoutInflater = MainContext.INSTANCE.getLayoutInflater(); view = layoutInflater.inflate(R.layout.channel_available_details, parent, false); } WiFiChannelCountry wiFiChannelCountry = getItem(position); ((TextView) view.findViewById(R.id.channel_available_country)) .setText(wiFiChannelCountry.getCountryCode() + " - " + wiFiChannelCountry.getCountryName()); ((TextView) view.findViewById(R.id.channel_available_title_ghz_2)).setText(WiFiBand.GHZ2.getBand() + " : "); ((TextView) view.findViewById(R.id.channel_available_ghz_2)) .setText(StringUtils.join(wiFiChannelCountry.getChannelsGHZ2().toArray(), ",")); ((TextView) view.findViewById(R.id.channel_available_title_ghz_5)).setText(WiFiBand.GHZ5.getBand() + " : "); ((TextView) view.findViewById(R.id.channel_available_ghz_5)) .setText(StringUtils.join(wiFiChannelCountry.getChannelsGHZ5().toArray(), ",")); return view; }
From source file:com.manning.androidhacks.hack028.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/* ww w. j a v a2 s . co m*/ mListView = (ListView) findViewById(R.id.main_listview); LayoutInflater inflator = LayoutInflater.from(this); mHeader = inflator.inflate(R.layout.header, mListView, false); mGallery = (Gallery) mHeader.findViewById(R.id.listview_header_gallery); mGallery.setAdapter(new ImageAdapter(this)); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT); mHeader.setLayoutParams(params); mListView.addHeaderView(mHeader, null, false); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, NUMBERS); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mGallery.setSelection(position - 1, true); } }); }