I have a small problem with a list of data .. At the beginning the data appear well (As ordered in the XML) after scrole the list, the results are disordered ... help there are my codes and the xml file ..
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/selectableItemBackground">
<TextView
android:id = "@+id/txtGrupoAuto"
android:layout_width = "0dp"
app:layout_widthPercent="30%"
android:layout_height = "25dp"
android:textSize="12dp"
app:layout_marginLeftPercent="18%"
app:layout_marginTopPercent="0%"
android:padding = "5dp"
/>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/consart_titulos"
android:orientation="horizontal"
android:layout_width="0dp"
app:layout_marginTopPercent="5%"
android:layout_height="0dp"
app:layout_heightPercent="20%"
app:layout_widthPercent="100%"
android:background="#b9c9fe"
android:weightSum="100"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"><Spinner
android:id="@+id/spinnerCategoria"
app:layout_heightPercent="38%"
app:layout_widthPercent="90%"
android:paddingTop="1dp"
app:layout_marginLeftPercent="5%"
app:layout_marginTopPercent="5%"
/>
<Spinner
android:id="@+id/spinner"
app:layout_heightPercent="38%"
app:layout_widthPercent="90%"
android:gravity="top"
app:layout_marginLeftPercent="5%"
android:paddingTop="1dp"
android:textAlignment="center"
app:layout_marginTopPercent="60%"
/>
</android.support.percent.PercentRelativeLayout>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/g2titulosultimos"
android:orientation="horizontal"
app:layout_heightPercent="100%"
app:layout_widthPercent="100%"
app:layout_marginTopPercent="25%"
android:weightSum="100"
android:layout_below="@+id/g2titulos"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ListView
android:id="@+id/listView"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbars="horizontal"
app:layout_heightPercent="100%"
app:layout_widthPercent="100%"
android:listSelector="@drawable/item_background"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</ListView>
</android.support.percent.PercentRelativeLayout>
my java class
protected String doInBackground(String... strings) {
articulos = new ArrayList<>();
globalClass = (GlobalClass) getApplication();
final Intent intent = getIntent();
pArticulo = intent.getStringExtra("pBUSCA");
String url = globalClass.Get_urlserver() + "consultanew.php?token=" + Token_Recibido + "&MASTER=T&GENERICO=" + pArticulo + "";
HttpHandler sh = new HttpHandler();
JSONObject jsonStr = sh.makeServiceCall(url);
Log.e("Response 12: ", String.valueOf(jsonStr));
try {
js_primero = jsonStr.getJSONArray("CATEGORIA");
js_segundo = jsonStr.getJSONArray("MARCA");
jsonarray = jsonStr.getJSONArray("DETALLES");
for (int u = 0; u < jsonarray.length(); u++) {
JSONObject c = jsonarray.getJSONObject(u);
String codig = c.getString("codigo");
String des = c.getString("descrip");
String fabri = c.getString("fabricante");
String rubro = c.getString("modelo");
String repue = c.getString("Linea");
double prec = Double.parseDouble(c.getString("precio"));
numeros=prec;
porcentaje=num;
calculo= (porcentaje / 100)*numeros;
HashMap<String, String> HMrellenar = new HashMap<>();
// NuevoP = Integer.parseInt(String.valueOf(prec));
Log.e("TAGUER", String.valueOf(prec));
Log.e("TAGio", String.valueOf(num));
Log.e("TAG", String.valueOf(porcentaje));
double NuevoP =prec * 1+(calculo);
Log.e("TAGUEREX", String.valueOf(NuevoP));
HMrellenar.put("codigo", codig);
HMrellenar.put("descrip", des);
HMrellenar.put("fabricante", fabri);
HMrellenar.put("modelo", rubro);
HMrellenar.put("Linea", repue);
HMrellenar.put("precio", String.valueOf(NuevoP));
articulos.add(HMrellenar);
}
ERROR=""+jsonStr;
} catch (final JSONException e) {
Log.e("Json parsing error: ", e.getMessage());
}
return por;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
if (pDialog.isShowing())
pDialog.dismiss();
grupoAuto.setText(GrupoNombre);
Primero = new Adapter(Consultageneral.this, js_primero);
Spinnercategorias.setAdapter((SpinnerAdapter) Primero);
final ListAdapter adapter = new SimpleAdapter(Consultageneral.this, articulos,
R.layout.item_catego, new String[]{"codigo", "descrip", "fabricante", "modelo", "Linea", "precio"},
new int[]{R.id.txtCodigo, R.id.txtdescart , R.id.txtFabri , R.id.txtrubro , R.id.txtGrupo , R.id.txtP});
lista.setAdapter(adapter);
registerForContextMenu(lista);