javiandroid94
27/06/17, 19:59:08
Tengo una base de datos que vuelco en un listview, al pulsar en el botón del listview paso a otro Activiy, necesito saber que elemento de la lista es el seleccionado.
He añadido un toast para saber que posicion obtenia pero era siempre 0.
Mi codigo:
public class MainActivity extends AppCompatActivity implements View.OnClickListener,AdapterView.OnItemClickListen er {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
public void pulsao(View v){
Toast.makeText(context, "id es "+posicion1, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, Pago.class);
startActivity(intent);
}
Context context;
Button consultar;
ListView lista;
String rdia,rmes,rano,rhora,rminutos;
//Button consultarporid;
/*EditText idendificador;
EditText nombre;
EditText direccion;
TextView resultado;
ImageView imageView;
*/
// IP de mi Url
String IP = "http://alquilalo.esy.es";
// Rutas de los Web Services
String GET = IP + "/obtener_alumnos.php";
String GET_BY_ID = IP + "/obtener_alumno_por_id_imagen.php";
String IMAGENES = IP + "/imagenes/";
ObtenerWebService hiloconexion;
int posicion1;
private ListView.OnItemClickListener onClickListView = new ListView.OnItemClickListener()
{
@Override
public void onItemClick(final AdapterView<?> adapter, View v, int position, long arg3)
{
//Ahora position tiene el valor de la posición del elemento clickado en el listview
posicion1=position;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
rdia =getIntent().getExtras().getString("rdia");
rmes =getIntent().getExtras().getString("rmes");
rano =getIntent().getExtras().getString("rano");
rhora =getIntent().getExtras().getString("rhora");
rminutos =getIntent().getExtras().getString("rminutos");
context=this;
lista = (ListView) findViewById(R.id.listView1);
lista.setOnItemClickListener(onClickListView);
// Enlaces con elementos visuales del XML
//resultado = (TextView)findViewById(R.id.resultado);
consultar = (Button)findViewById(R.id.consultar);
//consultarporid = (Button)findViewById(R.id.consultarid);
// idendificador = (EditText)findViewById(R.id.eid);
//nombre = (EditText)findViewById(R.id.enombre);
//direccion = (EditText)findViewById(R.id.edireccion);
//resultado = (TextView)findViewById(R.id.resultado);
//imageView=(ImageView)findViewById(R.id.imageView);
// Listener de los botones
consultar.setOnClickListener(this);
// consultarporid.setOnClickListener(this);
}
public Context getContext(){
return context;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.consultar:
hiloconexion = new ObtenerWebService();
hiloconexion.execute(GET,"1"); // Parámetros que recibe doInBackground
break;
default:
break;
}
}
/* public int ObtenerLongitudTabla(){
int longitud=15;
String cadena ="http://alquilalo.esy.es/obtener_alumnos.php" ;
URL url = null; // Url de donde queremos obtener información
try {
url = new URL(cadena);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Abrir la conexión
connection.setRequestProperty("User-Agent", "Mozilla/5.0" +
" (Linux; Android 1.5; es-ES) Ejemplo HTTP");
//connection.setHeader("content-type", "application/json");
int respuesta = connection.getResponseCode();
StringBuilder result = new StringBuilder();
if (respuesta == HttpURLConnection.HTTP_OK) {
InputStream in = new BufferedInputStream(connection.getInputStream()); // preparo la cadena de entrada
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); // la introduzco en un BufferedReader
// El siguiente proceso lo hago porque el JSONOBject necesita un String y tengo
// que tranformar el BufferedReader a String. Esto lo hago a traves de un
// StringBuilder.
String line;
while ((line = reader.readLine()) != null) {
result.append(line); // Paso toda la entrada al StringBuilder
}
//Creamos un objeto JSONObject para poder acceder a los atributos (campos) del objeto.
JSONObject respuestaJSON = new JSONObject(result.toString()); //Creo un JSONObject a partir del StringBuilder pasado a cadena
//Accedemos al vector de resultados
JSONArray alumnosJSON = respuestaJSON.getJSONArray("alumnos"); // estado es el nombre del campo en el JSON
longitud=alumnosJSON.length();
}
}
catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return longitud;
}
*/
public class ObtenerWebService extends AsyncTask<String,Void,String>{
//Bitmap bitmap;
Bitmap[] bitmap = new Bitmap[15];
//ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();
Bitmap bitmapotro;
ListViewAdapter adapter;
String[] titulo=new String[15];
String[] plazas=new String[15];
String[] puertas=new String[15];
String[] maletas=new String[15];
String[] aire=new String[15];
String[] transmision=new String[15];
String[] precio=new String[15];
@Override
protected String doInBackground(String... params) {
String cadena = params[0];
URL url = null; // Url de donde queremos obtener información
String devuelve ="";
if(params[1]=="1") { // Consulta de todos los alumnos
try {
url = new URL(cadena);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Abrir la conexión
connection.setRequestProperty("User-Agent", "Mozilla/5.0" +
" (Linux; Android 1.5; es-ES) Ejemplo HTTP");
//connection.setHeader("content-type", "application/json");
int respuesta = connection.getResponseCode();
StringBuilder result = new StringBuilder();
if (respuesta == HttpURLConnection.HTTP_OK) {
InputStream in = new BufferedInputStream(connection.getInputStream()); // preparo la cadena de entrada
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); // la introduzco en un BufferedReader
// El siguiente proceso lo hago porque el JSONOBject necesita un String y tengo
// que tranformar el BufferedReader a String. Esto lo hago a traves de un
// StringBuilder.
String line;
while ((line = reader.readLine()) != null) {
result.append(line); // Paso toda la entrada al StringBuilder
}
//Creamos un objeto JSONObject para poder acceder a los atributos (campos) del objeto.
JSONObject respuestaJSON = new JSONObject(result.toString()); //Creo un JSONObject a partir del StringBuilder pasado a cadena
//Accedemos al vector de resultados
String resultJSON = respuestaJSON.getString("estado"); // estado es el nombre del campo en el JSON
if (resultJSON.equals("1")) { // hay alumnos a mostrar
JSONArray alumnosJSON = respuestaJSON.getJSONArray("alumnos"); // estado es el nombre del campo en el JSON
for (int i = 0; i < alumnosJSON.length(); i++) {
//se va a poder eliminar el devuelve este de aqui abajo i think
devuelve = devuelve + alumnosJSON.getJSONObject(i).getString("rutaimagen") + " " + "\n";
if (alumnosJSON.getJSONObject(i).getString("rutaimagen").equals("noimagen")) {
bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.[I]ic_launcher);
titulo=alumnosJSON.getJSONObject(i).getString("modelo");
plazas[i]=alumnosJSON.getJSONObject(i).getString("plazas");
puertas[i]=alumnosJSON.getJSONObject(i).getString("puertas");
maletas[i]=alumnosJSON.getJSONObject(i).getString("maletas");
aire[i]=alumnosJSON.getJSONObject(i).getString("aire");
transmision[i]=alumnosJSON.getJSONObject(i).getString("transmision");
precio[i]=alumnosJSON.getJSONObject(i).getString("precio");
[I]//bitmapArray.add(bitmap);
} else {
URL urlimagen = new URL(IMAGENES + alumnosJSON.getJSONObject(i).getString("rutaimagen"));
HttpURLConnection conimagen = (HttpURLConnection) urlimagen.openConnection();
conimagen.connect();
bitmap = BitmapFactory.decodeStream(conimagen.getInputStrea m());
titulo[i]=alumnosJSON.getJSONObject(i).getString("modelo");
plazas[i]=alumnosJSON.getJSONObject(i).getString("plazas");
puertas[i]=alumnosJSON.getJSONObject(i).getString("puertas");
maletas[i]=alumnosJSON.getJSONObject(i).getString("maletas");
aire[i]=alumnosJSON.getJSONObject(i).getString("aire");
transmision[i]=alumnosJSON.getJSONObject(i).getString("transmision");
precio[i]=alumnosJSON.getJSONObject(i).getString("precio");
[I]//bitmapArray.add(bitmap);
}
}
} else if (resultJSON.equals("2")) {
devuelve = "No hay alumnos";
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return devuelve;
}
return null;
}
@Override
protected void onCancelled(String s) {
super.onCancelled(s);
}
@Override
protected void onPostExecute(String s) {
//resultado.setText(s);
//for (int i = 0; i < 5; i++) {
//
//imageView.setImageBitmap(bitmap);
//bitmap=bitmapArray.get(0);
//imageView.setImageBitmap(bitmap[0]);
//}
//imageView.setImageBitmap(bitmapotro);
//super.onPostExecute(s);
Context context = getContext();
adapter = new ListViewAdapter(context, titulo, bitmap,plazas,puertas,maletas,aire,transmision,pre cio);
lista.setAdapter(adapter);
//lista.setOnItemClickListener(ItemClicked item);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}
}
Mi listview:
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
String[] titulos;
Bitmap[] imagenes;
LayoutInflater inflater;
String[] plazas;
String[] puertas;
String[] maletas;
String[] aire;
String[] transmision;
String[] precio;
public ListViewAdapter(Context context, String[] titulos, Bitmap[] imagenes, String[] plazas,String[] puertas,String[] maletas,String[] aire,String[] transmision,String[] precio) {
this.context = context;
this.titulos = titulos;
this.imagenes = imagenes;
this.plazas=plazas;
this.puertas=puertas;
this.maletas=maletas;
this.aire=aire;
this.transmision=transmision;
this.precio=precio;
}
@Override
public int getCount() {
return titulos.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView txtTitle;
TextView txprecio;
ImageView imgImg;
TextView txplazas;
TextView txpuertas;
TextView txmaletas;
TextView txaire;
TextView txtransmision;
//http://developer.android.com/intl/es/reference/android/view/LayoutInflater.html
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_S ERVICE);
View itemView = inflater.inflate(R.layout.list_row, parent, false);
// Locate the TextViews in listview_item.xml
txtTitle = (TextView) itemView.findViewById(R.id.list_row_title);
imgImg = (ImageView) itemView.findViewById(R.id.list_row_image);
// Capture position and set to the TextViews
txtTitle.setText(titulos[position]);
imgImg.setImageBitmap(imagenes[position]);
txplazas = (TextView) itemView.findViewById(R.id.tplazas);
txpuertas = (TextView) itemView.findViewById(R.id.tpuertas);
txmaletas = (TextView) itemView.findViewById(R.id.tmaletas);
txaire = (TextView) itemView.findViewById(R.id.taire);
txtransmision = (TextView) itemView.findViewById(R.id.ttransmision);
txprecio = (TextView) itemView.findViewById(R.id.tprecio);
txtTitle.setText(titulos[position]);
imgImg.setImageBitmap(imagenes[position]);
txplazas.setText(plazas[position]);
txpuertas.setText(puertas[position]);
txmaletas.setText(maletas[position]);
txaire.setText(aire[position]);
txtransmision.setText(transmision[position]);
txprecio.setText(precio[position]);
return itemView;
}
}
He añadido un toast para saber que posicion obtenia pero era siempre 0.
Mi codigo:
public class MainActivity extends AppCompatActivity implements View.OnClickListener,AdapterView.OnItemClickListen er {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
public void pulsao(View v){
Toast.makeText(context, "id es "+posicion1, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, Pago.class);
startActivity(intent);
}
Context context;
Button consultar;
ListView lista;
String rdia,rmes,rano,rhora,rminutos;
//Button consultarporid;
/*EditText idendificador;
EditText nombre;
EditText direccion;
TextView resultado;
ImageView imageView;
*/
// IP de mi Url
String IP = "http://alquilalo.esy.es";
// Rutas de los Web Services
String GET = IP + "/obtener_alumnos.php";
String GET_BY_ID = IP + "/obtener_alumno_por_id_imagen.php";
String IMAGENES = IP + "/imagenes/";
ObtenerWebService hiloconexion;
int posicion1;
private ListView.OnItemClickListener onClickListView = new ListView.OnItemClickListener()
{
@Override
public void onItemClick(final AdapterView<?> adapter, View v, int position, long arg3)
{
//Ahora position tiene el valor de la posición del elemento clickado en el listview
posicion1=position;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
rdia =getIntent().getExtras().getString("rdia");
rmes =getIntent().getExtras().getString("rmes");
rano =getIntent().getExtras().getString("rano");
rhora =getIntent().getExtras().getString("rhora");
rminutos =getIntent().getExtras().getString("rminutos");
context=this;
lista = (ListView) findViewById(R.id.listView1);
lista.setOnItemClickListener(onClickListView);
// Enlaces con elementos visuales del XML
//resultado = (TextView)findViewById(R.id.resultado);
consultar = (Button)findViewById(R.id.consultar);
//consultarporid = (Button)findViewById(R.id.consultarid);
// idendificador = (EditText)findViewById(R.id.eid);
//nombre = (EditText)findViewById(R.id.enombre);
//direccion = (EditText)findViewById(R.id.edireccion);
//resultado = (TextView)findViewById(R.id.resultado);
//imageView=(ImageView)findViewById(R.id.imageView);
// Listener de los botones
consultar.setOnClickListener(this);
// consultarporid.setOnClickListener(this);
}
public Context getContext(){
return context;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.consultar:
hiloconexion = new ObtenerWebService();
hiloconexion.execute(GET,"1"); // Parámetros que recibe doInBackground
break;
default:
break;
}
}
/* public int ObtenerLongitudTabla(){
int longitud=15;
String cadena ="http://alquilalo.esy.es/obtener_alumnos.php" ;
URL url = null; // Url de donde queremos obtener información
try {
url = new URL(cadena);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Abrir la conexión
connection.setRequestProperty("User-Agent", "Mozilla/5.0" +
" (Linux; Android 1.5; es-ES) Ejemplo HTTP");
//connection.setHeader("content-type", "application/json");
int respuesta = connection.getResponseCode();
StringBuilder result = new StringBuilder();
if (respuesta == HttpURLConnection.HTTP_OK) {
InputStream in = new BufferedInputStream(connection.getInputStream()); // preparo la cadena de entrada
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); // la introduzco en un BufferedReader
// El siguiente proceso lo hago porque el JSONOBject necesita un String y tengo
// que tranformar el BufferedReader a String. Esto lo hago a traves de un
// StringBuilder.
String line;
while ((line = reader.readLine()) != null) {
result.append(line); // Paso toda la entrada al StringBuilder
}
//Creamos un objeto JSONObject para poder acceder a los atributos (campos) del objeto.
JSONObject respuestaJSON = new JSONObject(result.toString()); //Creo un JSONObject a partir del StringBuilder pasado a cadena
//Accedemos al vector de resultados
JSONArray alumnosJSON = respuestaJSON.getJSONArray("alumnos"); // estado es el nombre del campo en el JSON
longitud=alumnosJSON.length();
}
}
catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return longitud;
}
*/
public class ObtenerWebService extends AsyncTask<String,Void,String>{
//Bitmap bitmap;
Bitmap[] bitmap = new Bitmap[15];
//ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();
Bitmap bitmapotro;
ListViewAdapter adapter;
String[] titulo=new String[15];
String[] plazas=new String[15];
String[] puertas=new String[15];
String[] maletas=new String[15];
String[] aire=new String[15];
String[] transmision=new String[15];
String[] precio=new String[15];
@Override
protected String doInBackground(String... params) {
String cadena = params[0];
URL url = null; // Url de donde queremos obtener información
String devuelve ="";
if(params[1]=="1") { // Consulta de todos los alumnos
try {
url = new URL(cadena);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Abrir la conexión
connection.setRequestProperty("User-Agent", "Mozilla/5.0" +
" (Linux; Android 1.5; es-ES) Ejemplo HTTP");
//connection.setHeader("content-type", "application/json");
int respuesta = connection.getResponseCode();
StringBuilder result = new StringBuilder();
if (respuesta == HttpURLConnection.HTTP_OK) {
InputStream in = new BufferedInputStream(connection.getInputStream()); // preparo la cadena de entrada
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); // la introduzco en un BufferedReader
// El siguiente proceso lo hago porque el JSONOBject necesita un String y tengo
// que tranformar el BufferedReader a String. Esto lo hago a traves de un
// StringBuilder.
String line;
while ((line = reader.readLine()) != null) {
result.append(line); // Paso toda la entrada al StringBuilder
}
//Creamos un objeto JSONObject para poder acceder a los atributos (campos) del objeto.
JSONObject respuestaJSON = new JSONObject(result.toString()); //Creo un JSONObject a partir del StringBuilder pasado a cadena
//Accedemos al vector de resultados
String resultJSON = respuestaJSON.getString("estado"); // estado es el nombre del campo en el JSON
if (resultJSON.equals("1")) { // hay alumnos a mostrar
JSONArray alumnosJSON = respuestaJSON.getJSONArray("alumnos"); // estado es el nombre del campo en el JSON
for (int i = 0; i < alumnosJSON.length(); i++) {
//se va a poder eliminar el devuelve este de aqui abajo i think
devuelve = devuelve + alumnosJSON.getJSONObject(i).getString("rutaimagen") + " " + "\n";
if (alumnosJSON.getJSONObject(i).getString("rutaimagen").equals("noimagen")) {
bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.[I]ic_launcher);
titulo=alumnosJSON.getJSONObject(i).getString("modelo");
plazas[i]=alumnosJSON.getJSONObject(i).getString("plazas");
puertas[i]=alumnosJSON.getJSONObject(i).getString("puertas");
maletas[i]=alumnosJSON.getJSONObject(i).getString("maletas");
aire[i]=alumnosJSON.getJSONObject(i).getString("aire");
transmision[i]=alumnosJSON.getJSONObject(i).getString("transmision");
precio[i]=alumnosJSON.getJSONObject(i).getString("precio");
[I]//bitmapArray.add(bitmap);
} else {
URL urlimagen = new URL(IMAGENES + alumnosJSON.getJSONObject(i).getString("rutaimagen"));
HttpURLConnection conimagen = (HttpURLConnection) urlimagen.openConnection();
conimagen.connect();
bitmap = BitmapFactory.decodeStream(conimagen.getInputStrea m());
titulo[i]=alumnosJSON.getJSONObject(i).getString("modelo");
plazas[i]=alumnosJSON.getJSONObject(i).getString("plazas");
puertas[i]=alumnosJSON.getJSONObject(i).getString("puertas");
maletas[i]=alumnosJSON.getJSONObject(i).getString("maletas");
aire[i]=alumnosJSON.getJSONObject(i).getString("aire");
transmision[i]=alumnosJSON.getJSONObject(i).getString("transmision");
precio[i]=alumnosJSON.getJSONObject(i).getString("precio");
[I]//bitmapArray.add(bitmap);
}
}
} else if (resultJSON.equals("2")) {
devuelve = "No hay alumnos";
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return devuelve;
}
return null;
}
@Override
protected void onCancelled(String s) {
super.onCancelled(s);
}
@Override
protected void onPostExecute(String s) {
//resultado.setText(s);
//for (int i = 0; i < 5; i++) {
//
//imageView.setImageBitmap(bitmap);
//bitmap=bitmapArray.get(0);
//imageView.setImageBitmap(bitmap[0]);
//}
//imageView.setImageBitmap(bitmapotro);
//super.onPostExecute(s);
Context context = getContext();
adapter = new ListViewAdapter(context, titulo, bitmap,plazas,puertas,maletas,aire,transmision,pre cio);
lista.setAdapter(adapter);
//lista.setOnItemClickListener(ItemClicked item);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}
}
Mi listview:
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
String[] titulos;
Bitmap[] imagenes;
LayoutInflater inflater;
String[] plazas;
String[] puertas;
String[] maletas;
String[] aire;
String[] transmision;
String[] precio;
public ListViewAdapter(Context context, String[] titulos, Bitmap[] imagenes, String[] plazas,String[] puertas,String[] maletas,String[] aire,String[] transmision,String[] precio) {
this.context = context;
this.titulos = titulos;
this.imagenes = imagenes;
this.plazas=plazas;
this.puertas=puertas;
this.maletas=maletas;
this.aire=aire;
this.transmision=transmision;
this.precio=precio;
}
@Override
public int getCount() {
return titulos.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView txtTitle;
TextView txprecio;
ImageView imgImg;
TextView txplazas;
TextView txpuertas;
TextView txmaletas;
TextView txaire;
TextView txtransmision;
//http://developer.android.com/intl/es/reference/android/view/LayoutInflater.html
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_S ERVICE);
View itemView = inflater.inflate(R.layout.list_row, parent, false);
// Locate the TextViews in listview_item.xml
txtTitle = (TextView) itemView.findViewById(R.id.list_row_title);
imgImg = (ImageView) itemView.findViewById(R.id.list_row_image);
// Capture position and set to the TextViews
txtTitle.setText(titulos[position]);
imgImg.setImageBitmap(imagenes[position]);
txplazas = (TextView) itemView.findViewById(R.id.tplazas);
txpuertas = (TextView) itemView.findViewById(R.id.tpuertas);
txmaletas = (TextView) itemView.findViewById(R.id.tmaletas);
txaire = (TextView) itemView.findViewById(R.id.taire);
txtransmision = (TextView) itemView.findViewById(R.id.ttransmision);
txprecio = (TextView) itemView.findViewById(R.id.tprecio);
txtTitle.setText(titulos[position]);
imgImg.setImageBitmap(imagenes[position]);
txplazas.setText(plazas[position]);
txpuertas.setText(puertas[position]);
txmaletas.setText(maletas[position]);
txaire.setText(aire[position]);
txtransmision.setText(transmision[position]);
txprecio.setText(precio[position]);
return itemView;
}
}