Search in sources :

Example 61 with LayoutInflater

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) Milestone(com.meisolsson.githubsdk.model.Milestone) BaseActivity(com.github.pockethub.android.ui.BaseActivity) Activity(android.app.Activity) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) DialogAction(com.afollestad.materialdialogs.DialogAction) LayoutInflater(android.view.LayoutInflater)

Example 62 with LayoutInflater

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));
}
Also used : LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout)

Example 63 with LayoutInflater

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;
}
Also used : LayoutInflater(android.view.LayoutInflater) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView)

Example 64 with LayoutInflater

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);
}
Also used : ViewFlipper(android.widget.ViewFlipper) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 65 with LayoutInflater

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;
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View)

Aggregations

LayoutInflater (android.view.LayoutInflater)1292 View (android.view.View)803 TextView (android.widget.TextView)615 ImageView (android.widget.ImageView)259 ViewGroup (android.view.ViewGroup)139 Context (android.content.Context)131 ListView (android.widget.ListView)123 LinearLayout (android.widget.LinearLayout)106 RecyclerView (android.support.v7.widget.RecyclerView)104 AdapterView (android.widget.AdapterView)100 Intent (android.content.Intent)92 AlertDialog (android.app.AlertDialog)88 DialogInterface (android.content.DialogInterface)81 Button (android.widget.Button)57 Bundle (android.os.Bundle)54 FrameLayout (android.widget.FrameLayout)49 TypedArray (android.content.res.TypedArray)43 Activity (android.app.Activity)41 AlertDialog (android.support.v7.app.AlertDialog)41 EditText (android.widget.EditText)41