use of android.view.LayoutInflater in project PocketHub by pockethub.
the class MilestoneDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Activity activity = getActivity();
Bundle arguments = getArguments();
final MaterialDialog.Builder dialogBuilder = createDialogBuilder().negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
MilestoneDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
}
}).neutralText(R.string.clear).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
MilestoneDialogFragment.this.onClick(dialog, BUTTON_NEUTRAL);
}
});
LayoutInflater inflater = activity.getLayoutInflater();
ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
view.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onClick(getDialog(), position);
}
});
ArrayList<Milestone> choices = getChoices();
int selected = arguments.getInt(ARG_SELECTED_CHOICE);
MilestoneListAdapter adapter = new MilestoneListAdapter(inflater, choices.toArray(new Milestone[choices.size()]), selected);
view.setAdapter(adapter);
if (selected >= 0) {
view.setSelection(selected);
}
dialogBuilder.customView(view, false);
return dialogBuilder.build();
}
use of android.view.LayoutInflater in project platform_frameworks_base by android.
the class DpiTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
this.setTitle(R.string.act_title);
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
LinearLayout layout = new LinearLayout(this);
addBitmapDrawable(layout, R.drawable.logo120dpi, true);
addBitmapDrawable(layout, R.drawable.logo160dpi, true);
addBitmapDrawable(layout, R.drawable.logo240dpi, true);
addLabelToRoot(root, "Prescaled bitmap in drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addBitmapDrawable(layout, R.drawable.logo120dpi, false);
addBitmapDrawable(layout, R.drawable.logo160dpi, false);
addBitmapDrawable(layout, R.drawable.logo240dpi, false);
addLabelToRoot(root, "Autoscaled bitmap in drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addResourceDrawable(layout, R.drawable.logo120dpi);
addResourceDrawable(layout, R.drawable.logo160dpi);
addResourceDrawable(layout, R.drawable.logo240dpi);
addLabelToRoot(root, "Prescaled resource drawable");
addChildToRoot(root, layout);
layout = (LinearLayout) li.inflate(R.layout.image_views, null);
addLabelToRoot(root, "Inflated layout");
addChildToRoot(root, layout);
layout = (LinearLayout) li.inflate(R.layout.styled_image_views, null);
addLabelToRoot(root, "Inflated styled layout");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addCanvasBitmap(layout, R.drawable.logo120dpi, true);
addCanvasBitmap(layout, R.drawable.logo160dpi, true);
addCanvasBitmap(layout, R.drawable.logo240dpi, true);
addLabelToRoot(root, "Prescaled bitmap");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addCanvasBitmap(layout, R.drawable.logo120dpi, false);
addCanvasBitmap(layout, R.drawable.logo160dpi, false);
addCanvasBitmap(layout, R.drawable.logo240dpi, false);
addLabelToRoot(root, "Autoscaled bitmap");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addResourceDrawable(layout, R.drawable.logonodpi120);
addResourceDrawable(layout, R.drawable.logonodpi160);
addResourceDrawable(layout, R.drawable.logonodpi240);
addLabelToRoot(root, "No-dpi resource drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch120dpi);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch160dpi);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch240dpi);
addLabelToRoot(root, "Prescaled 9-patch resource drawable");
addChildToRoot(root, layout);
setContentView(scrollWrap(root));
}
use of android.view.LayoutInflater in project androidquery by androidquery.
the class AbstractAQuery method inflate.
/**
* Inflate a view from xml layout.
*
* This method is similar to LayoutInflater.inflate() but with sanity checks against the
* layout type of the convert view.
*
* If the convertView is null or the convertView type doesn't matches layoutId type, a new view
* is inflated. Otherwise the convertView will be returned for reuse.
*
* @param convertView the view to be reused
* @param layoutId the desired view type
* @param root the view root for layout params, can be null
* @return self
*
*/
public View inflate(View convertView, int layoutId, ViewGroup root) {
if (convertView != null) {
Integer layout = (Integer) convertView.getTag(AQuery.TAG_LAYOUT);
if (layout != null && layout.intValue() == layoutId) {
return convertView;
}
}
LayoutInflater inflater = null;
if (act != null) {
inflater = act.getLayoutInflater();
} else {
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
View view = inflater.inflate(layoutId, root, false);
view.setTag(AQuery.TAG_LAYOUT, layoutId);
return view;
}
use of android.view.LayoutInflater in project platform_frameworks_base by android.
the class ViewFlipperActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LayoutInflater inflater = getLayoutInflater();
final View widget = inflater.inflate(R.layout.widget, null);
widget.setLayoutParams(new FrameLayout.LayoutParams(180, 180, Gravity.CENTER));
ViewFlipper flipper = (ViewFlipper) widget.findViewById(R.id.flipper);
View view = inflater.inflate(R.layout.flipper_item, flipper, false);
flipper.addView(view);
((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset1);
((TextView) view.findViewById(R.id.widget_text)).setText("This is a long line of text, " + "enjoy the wrapping and drawing");
view = inflater.inflate(R.layout.flipper_item, flipper, false);
flipper.addView(view);
((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset3);
((TextView) view.findViewById(R.id.widget_text)).setText("Another very long line of text, " + "enjoy the wrapping and drawing");
FrameLayout layout = new FrameLayout(this);
layout.addView(widget);
setContentView(layout);
}
use of android.view.LayoutInflater in project MediaRouter-Cast-Button-android by googlecast.
the class CustomMediaRouteControllerDialog method onCreateMediaControlView.
@Override
public View onCreateMediaControlView(Bundle savedInstanceState) {
LayoutInflater inflater = getLayoutInflater();
View customView = inflater.inflate(R.layout.custom_media_router_controller_dialog_fragment, null);
mTextView = (TextView) customView.findViewById(R.id.title);
mTextView.setText(R.string.custom_media_router_control_dialog_text);
return customView;
}
Aggregations