Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:cl.gisred.android.CatastroActivity.java

public void setActionsDialog(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    v.setMinimumWidth(400);/*  w  w  w .  j  a va 2 s  .c  om*/

    dialogCrear.setTitle(sNombre);
    dialogCrear.setContentView(v);
    idResLayoutSelect = idRes;

    setSpinnerDialog(idRes, v);

    if (idRes != R.layout.dialog_poste) {
        setButtonAsociacion(v);
    }

    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            bMapTap = true;
            dialogCrear.hide();
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarDialogCrear(false, null);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarDialogCrear(true, v);
        }
    });

    arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);

    dialogCrear.show();
    dialogCur = dialogCrear;
}

From source file:cl.gisred.android.MantCatastroActivity.java

public void setDataFormMant(final int idRes, final String sTipo, String sRotulo) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;//w ww  . j a v a  2 s. c  o m

    v.setMinimumWidth(widthScale);

    formMant.setTitle("Mantencin " + sTipo);
    formMant.setContentView(v);

    TextView tvTipo = (TextView) v.findViewById(R.id.tvTipoRotulo);
    tvTipo.setText(sTipo + ": " + sRotulo);

    if (sTipo.equals("Poste"))
        arrayElements = getResources().getStringArray(R.array.elementos_postes);
    else
        arrayElements = getResources().getStringArray(R.array.elementos_camaras);

    spElements = (Spinner) v.findViewById(R.id.spinnerElement);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayElements);
    spElements.setAdapter(adapter);

    spElements.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            bindSpinnerMant(sTipo, i, v);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormMant(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormMant(true, v);
        }
    });

    formMant.show();
}

From source file:cl.gisred.android.MedidorActivity.java

public void setActionsForm(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*www. ja v a2  s .  co m*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    Spinner spUserCosenza = (Spinner) v.findViewById(R.id.spinnerUser);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayUserCosenza);
    spUserCosenza.setAdapter(adapter);

    Spinner spEstado = (Spinner) v.findViewById(R.id.spinnerEstado);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEstado);
    spEstado.setAdapter(adapter);

    Spinner spTipoEdif = (Spinner) v.findViewById(R.id.spinnerTipoEdific);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayTipoEdif);
    spTipoEdif.setAdapter(adapter);

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            Log.w("[LectorActivity]", "HIDE FORM POSTE and Zoom");
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnIdentDireccion = (ImageButton) v.findViewById(R.id.btnDireccion);
    btnIdentDireccion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddDireccion;
            oLyExistAsoc = LyDIRECCIONES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            bMapTap = true;
            formCrear.hide();
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v);
        }
    });

    arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:cl.gisred.android.LectorActivity.java

public void setActionsForm(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/* w w  w  . j a v  a  2 s . com*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    if (idRes == R.layout.form_lectores) {
        Spinner spUserCosenza = (Spinner) v.findViewById(R.id.spinnerUser);
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayUserCosenza);
        spUserCosenza.setAdapter(adapter);
    }

    Spinner spEstado = (Spinner) v.findViewById(R.id.spinnerEstado);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEstado);
    spEstado.setAdapter(adapter);

    Spinner spTipoEdif = (Spinner) v.findViewById(R.id.spinnerTipoEdific);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayTipoEdif);
    spTipoEdif.setAdapter(adapter);

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnIdentDireccion = (ImageButton) v.findViewById(R.id.btnDireccion);
    btnIdentDireccion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddDireccion;
            oLyExistAsoc = LyDIRECCIONES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            bMapTap = true;
            formCrear.hide();
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v);
        }
    });

    arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:com.benefit.buy.library.http.query.AbstractAQuery.java

/**
 * 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/*from   w  w w  .  j  a va  2s  . c om*/
 */
public View inflate(View convertView, int layoutId, ViewGroup root) {
    if (convertView != null) {
        Integer layout = (Integer) convertView.getTag(Constants.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(Constants.TAG_LAYOUT, layoutId);
    return view;
}

From source file:com.android.messaging.ui.conversation.ConversationFragment.java

public void updateActionBar(final ActionBar actionBar) {
    if (mComposeMessageView == null || !mComposeMessageView.updateActionBar(actionBar)) {
        updateActionAndStatusBarColor(actionBar);
        // We update this regardless of whether or not the action bar is showing so that we
        // don't get a race when it reappears.
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setDisplayHomeAsUpEnabled(true);
        // Reset the back arrow to its default
        actionBar.setHomeAsUpIndicator(0);
        View customView = actionBar.getCustomView();
        if (customView == null || customView.getId() != R.id.conversation_title_container) {
            final LayoutInflater inflator = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            customView = inflator.inflate(R.layout.action_bar_conversation_name, null);
            customView.setOnClickListener(new View.OnClickListener() {
                @Override//from  w w  w .j  a  va 2 s  .  c o  m
                public void onClick(final View v) {
                    onBackPressed();
                }
            });
            actionBar.setCustomView(customView);
        }

        final TextView conversationNameView = (TextView) customView.findViewById(R.id.conversation_title);
        final String conversationName = getConversationName();
        if (!TextUtils.isEmpty(conversationName)) {
            // RTL : To format conversation title if it happens to be phone numbers.
            final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
            final String formattedName = bidiFormatter.unicodeWrap(UiUtils.commaEllipsize(conversationName,
                    conversationNameView.getPaint(), conversationNameView.getWidth(),
                    getString(R.string.plus_one), getString(R.string.plus_n)).toString(),
                    TextDirectionHeuristicsCompat.LTR);
            conversationNameView.setText(formattedName);
            // In case phone numbers are mixed in the conversation name, we need to vocalize it.
            final String vocalizedConversationName = AccessibilityUtil.getVocalizedPhoneNumber(getResources(),
                    conversationName);
            conversationNameView.setContentDescription(vocalizedConversationName);
            getActivity().setTitle(conversationName);
        } else {
            final String appName = getString(R.string.app_name);
            conversationNameView.setText(appName);
            getActivity().setTitle(appName);
        }

        // When conversation is showing and media picker is not showing, then hide the action
        // bar only when we are in landscape mode, with IME open.
        if (mHost.isImeOpen() && UiUtils.isLandscapeMode()) {
            actionBar.hide();
        } else {
            actionBar.show();
        }
    }
}

From source file:com.androidquery.AbstractAQuery.java

/**
 * Inflate a view from xml layout./*from w  ww .  ja va2  s. c  o  m*/
 * 
 * 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;

}

From source file:cl.gisred.android.InspActivity.java

public void dialogBusqueda() {

    AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this);
    dialogBusqueda.setTitle("Busqueda");
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflater.inflate(R.layout.dialog_busqueda, null);
    dialogBusqueda.setView(v);/*from  w w  w . j  ava2 s  . c  o m*/

    Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda);
    final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar);
    final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            R.layout.support_simple_spinner_dropdown_item, searchArray);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            SpiBusqueda = position;

            if (position != 4) {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.GONE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.VISIBLE);
            } else {
                if (llDireccion != null)
                    llDireccion.setVisibility(View.VISIBLE);
                if (llBuscar != null)
                    llBuscar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show();
        }
    });

    final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar);
    final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle);
    final EditText eNumber = (EditText) v.findViewById(R.id.txtNum);

    dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            if (SpiBusqueda == 4) {
                txtBusqueda = new String();
                if (!eStreet.getText().toString().isEmpty())
                    txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 "
                            : eNumber.getText().toString().trim() + " ";
                txtBusqueda = txtBusqueda + eStreet.getText().toString();
            } else {
                if (SpiBusqueda > 1)
                    txtBusqueda = eSearch.getText().toString();
                else
                    txtBusqueda = Util.extraerNum(eSearch.getText().toString());
            }

            if (txtBusqueda.trim().isEmpty()) {
                Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show();
            } else {
                // Escala de calle para busquedas por default
                // TODO Asignar a res values o strings
                iBusqScale = 4000;
                switch (SpiBusqueda) {
                case 0:
                    callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"),
                            LyCLIENTES.getUrl().concat("/0"));
                    if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0)
                        iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 1:
                    callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1"));
                    if (LySED.getLayers() != null && LySED.getLayers().length > 1)
                        iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale();
                    break;
                case 2:
                    callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0"));
                    if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0)
                        iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                case 3:
                    callQuery(txtBusqueda, "serie_medidor", LyMEDIDORES.getUrl().concat("/1"));
                    if (LyMEDIDORES.getLayers() != null && LyMEDIDORES.getLayers().length > 1)
                        iBusqScale = LyMEDIDORES.getLayers()[1].getLayerServiceInfo().getMinScale();
                    break;
                case 4:
                    iBusqScale = 5000;
                    String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() };
                    String[] sFields = { "nombre_calle", "numero" };
                    callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0"));
                    break;
                case 5:
                    callQuery(txtBusqueda, new String[] { "id_equipo", "nombre" },
                            LyEQUIPOSLINEA.getUrl().concat("/0"));
                    if (LyEQUIPOSLINEA.getLayers() != null && LyEQUIPOSLINEA.getLayers().length > 0)
                        iBusqScale = LyEQUIPOSLINEA.getLayers()[0].getLayerServiceInfo().getMinScale();
                    break;
                }
            }
        }
    });

    dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    dialogBusqueda.show();
}

From source file:cl.gisred.android.RegEquipoActivity.java

public void setActionsFormAgr(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*from  ww w  .  j a va2  s.c om*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    Spinner spFaseConex = (Spinner) v.findViewById(R.id.spinnerFaseCon);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayfaseConex);
    spFaseConex.setAdapter(adapter);

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnTramoBt = (ImageButton) v.findViewById(R.id.btnTramoBt);
    btnTramoBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            nIndentify = 2; //2 = valor para tramo
            oLySelectAsoc = LyAsocTramo;
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormLimit(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormLimit(true, v);
        }
    });

    formCrear.show();
    dialogCur = formCrear;
}

From source file:cl.gisred.android.MicroMedidaActivity.java

public void setActionsFormLimit(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;//from  w  ww. j a va 2s .co  m

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnTramoBt = (ImageButton) v.findViewById(R.id.btnTramoBt);
    btnTramoBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            nIndentify = 2; //2 = valor para tramo
            oLySelectAsoc = LyAsocTramo;
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormLimit(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormLimit(true, v);
        }
    });

    formCrear.show();
    dialogCur = formCrear;
}