Skip to content

Instantly share code, notes, and snippets.

@gvr23
Created January 13, 2018 01:53
Show Gist options
  • Save gvr23/1a85b861d3fba42c61a1736a2f03d48a to your computer and use it in GitHub Desktop.
Save gvr23/1a85b861d3fba42c61a1736a2f03d48a to your computer and use it in GitHub Desktop.
Manera antigua de inflar un LinearLayout
ANDROID
================================================================================================================================
private void insertarRowDocumento(final DocumentoBean document) {
if (document != null) {
LinearLayout nuevoParticipante = new LinearLayout(getContext());
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
View rootView = inflater.inflate(R.layout.document_row, null);
TextView tvTipoDoc = rootView.findViewById(R.id.tvTipoDoc);
TextView tvNumero = rootView.findViewById(R.id.tvNumero);
TextView tvCambio = rootView.findViewById(R.id.tvCambio);
TextView tvPorcAvance = rootView.findViewById(R.id.tvPorcAvance);
TextView tvRecargo = rootView.findViewById(R.id.tvRecargo);
TextView tvMonto = rootView.findViewById(R.id.tvMonto);
tvTipoDoc.setText((document.getCodTipoDoc() == null) ? "-" : document.getCodTipoDoc());
tvNumero.setText((document.getNumdoc() == null) ? "-" : document.getNumdoc());
tvCambio.setText((document.getTcambio() == null) ? "-" : document.getTcambio());
tvPorcAvance.setText((document.getPorcpago() == null) ? "-" : document.getPorcpago());
tvRecargo.setText((document.getRecargo() == null) ? "-" : document.getRecargo());
tvMonto.setText((document.getMbruto() == null) ? "-" : document.getMbruto());
nuevoParticipante.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), LiquidationClientActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("client", client);
intent.putExtras(bundle);
startActivity(intent);
}
});
nuevoParticipante.setLayoutParams(layoutParams);
nuevoParticipante.addView(rootView);
// lnRowNewDocument.addView(nuevoParticipante, lnRowNewDocument.getChildCount());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment