I'm populating a list view with parse data and I'm querying the data. I want to show only the rows equal to a string coming from another activity.
I get the string because I have a toast that shows me the string but the string in the query.whereEqualTo is void.
How I pass the value of the string variable inside the doInBackground?
This is my code,
public class ListadoMusica extends Activity {
String año; String artista; // Declare Variables ListView listview; List<ParseObject> ob; ProgressDialog mProgressDialog; CustomAdapter adapter; private List<Musica> musica = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the view from listview_main.xml setContentView(R.layout.activity_listado_musica); año = getIntent().getStringExtra("myaño"); artista = getIntent().getStringExtra("myartista"); Toast.makeText(getApplicationContext(),año, Toast.LENGTH_SHORT).show(); // Execute RemoteDataTask AsyncTask new RemoteDataTask().execute(); } // RemoteDataTask AsyncTask private class RemoteDataTask extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); // Create a progressdialog mProgressDialog = new ProgressDialog(ListadoMusica.this); // Set progressdialog title mProgressDialog.setTitle("Cargando..."); // Set progressdialog message mProgressDialog.setMessage("Loading..."); mProgressDialog.setIndeterminate(false); // Show progressdialog mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { // Create the array musica = new ArrayList<Musica>(); try { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>( "Musica"); // Locate the column named "ranknum" in Parse.com and order list // by ascending //query.orderByAscending("createdAt"); query.whereEqualTo("año", año); query.whereEqualTo("artista", artista); ob = query.find(); for (ParseObject country : ob) { // Locate images in flag column ParseFile image = (ParseFile) country.get("imagen"); Musica map = new Musica(); map.setTitulo((String) country.get("titulo")); map.setArtista((String) country.get("artista")); map.setAño((String) country.get("año")); map.setFoto(image.getUrl()); musica.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { // Locate the listview in listview_main.xml listview = (ListView) findViewById(R.id.listview); // Pass the results into ListViewAdapter.java adapter = new CustomAdapter(ListadoMusica.this, musica); // Binds the Adapter to the ListView listview.setAdapter(adapter); // Close the progressdialog mProgressDialog.dismiss(); } }
}
Thanks in advance,