|
1 | 1 | package com.example.cityreport; |
2 | 2 |
|
3 | 3 | import androidx.appcompat.app.AppCompatActivity; |
| 4 | +import androidx.core.content.ContextCompat; |
4 | 5 |
|
5 | 6 | import android.app.ProgressDialog; |
6 | 7 | import android.content.Intent; |
7 | 8 | import android.os.Bundle; |
| 9 | +import android.view.Gravity; |
| 10 | +import android.view.View; |
| 11 | +import android.view.ViewGroup; |
8 | 12 | import android.widget.ImageView; |
9 | 13 | import android.widget.TableLayout; |
10 | 14 | import android.widget.TableRow; |
@@ -78,31 +82,63 @@ public void onResponse(JSONObject response) { |
78 | 82 | String descripcion = reporte.getString("descripcion"); |
79 | 83 | String estado = reporte.getString("estado"); |
80 | 84 |
|
| 85 | + TableRow.LayoutParams lP = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT); |
| 86 | + lP.setMargins(20,5,10,5); |
| 87 | + lP.gravity = Gravity.CENTER_VERTICAL; |
| 88 | + |
81 | 89 | TextView viewId = new TextView(ReportsActivity.this); |
82 | 90 | viewId.setText(String.valueOf(id)); |
| 91 | + viewId.setLayoutParams(lP); |
| 92 | + |
83 | 93 |
|
84 | 94 | TextView viewDescripcion = new TextView(ReportsActivity.this); |
85 | 95 | viewDescripcion.setText(descripcion); |
| 96 | + viewDescripcion.setLayoutParams(lP); |
| 97 | + viewDescripcion.setMaxLines(20); //Saltos de linea en la descripcion |
| 98 | + |
| 99 | + |
| 100 | + //TextView viewEstado = new TextView(ReportsActivity.this); |
| 101 | + //viewEstado.setText(estado); |
86 | 102 |
|
87 | | - TextView viewEstado = new TextView(ReportsActivity.this); |
88 | | - viewEstado.setText(estado); |
89 | 103 |
|
90 | | - // ImageView viewEstado= new ImageView(ReportsActivity.this); |
91 | | - // viewFoto.setImageResource(R.drawable.person); |
92 | 104 |
|
93 | | - Toast.makeText(ReportsActivity.this,"REPORTE "+id+" - "+descripcion+" - "+ estado,Toast.LENGTH_LONG).show(); |
| 105 | + final ImageView viewEstado = new ImageView(ReportsActivity.this); |
| 106 | + viewEstado.setLayoutParams(lP); |
| 107 | + viewEstado.setContentDescription(id +" - "+ estado); //almacenamos el estado del reporte para el onClick |
| 108 | + if(estado.equals("pendiente")) |
| 109 | + viewEstado.setImageResource(R.drawable.ic_exclamation_red); |
| 110 | + else if (estado.equals("revisado")) |
| 111 | + viewEstado.setImageResource(R.drawable.ic_exclamation_orange); |
| 112 | + else if(estado.equals("finalizado")) |
| 113 | + viewEstado.setImageResource(R.drawable.ic_exclamation_green); |
| 114 | + else |
| 115 | + viewEstado.setImageResource(R.drawable.ic_exclamation); |
| 116 | + |
| 117 | + viewEstado.setOnClickListener(new View.OnClickListener() { |
| 118 | + @Override |
| 119 | + public void onClick(View v) { |
| 120 | + Toast.makeText(ReportsActivity.this, |
| 121 | + viewEstado.getContentDescription(), |
| 122 | + Toast.LENGTH_SHORT).show(); |
| 123 | + } |
| 124 | + }); |
| 125 | + |
| 126 | + //Toast.makeText(ReportsActivity.this,"REPORTE "+id+" - "+descripcion+" - "+ estado,Toast.LENGTH_LONG).show(); |
94 | 127 |
|
95 | 128 |
|
96 | 129 | /* Create a new row to be added. */ |
97 | 130 | TableRow tr = new TableRow(ReportsActivity.this); |
98 | | - tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
| 131 | + tr.setBackground(ContextCompat.getDrawable(ReportsActivity.this, R.drawable.border)); |
| 132 | + |
| 133 | + //tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
| 134 | + |
99 | 135 |
|
100 | 136 | tr.addView(viewId); |
101 | 137 | tr.addView(viewDescripcion); |
102 | 138 | tr.addView(viewEstado); |
103 | 139 | /* Add row to TableLayout. */ |
104 | 140 | //tr.setBackgroundResource(R.drawable.sf_gradient_03); |
105 | | - tablaReportes.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); |
| 141 | + tablaReportes.addView(tr); |
106 | 142 |
|
107 | 143 | } |
108 | 144 | } catch (JSONException e) { |
|
0 commit comments