There is a Parse.com table with 20 values, ListView downloads each value (regardless of whether there is content or not). It turns out that when there are only 2-3 text in the parse, the listView downloads these 2-3 texts and leaves the remaining 18 lines empty. What is the condition to create so that empty lines are not downloaded? P / S / delete lines from Pars can not.

Code:

private class RemoteDataTask extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); // Create a progressdialog mProgressDialog = new ProgressDialog(SevenActivity.this); // Set progressdialog title mProgressDialog.setTitle("LikedFar"); // Set progressdialog message mProgressDialog.setMessage("Загрузка..."); mProgressDialog.setIndeterminate(false); // Show progressdialog mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>( "LikedFar"); // query.orderByDescending("_created_at"); try { ob = query.find(); } 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 an ArrayAdapter adapter = new ArrayAdapter<String>(SevenActivity.this, R.layout.listview_item); // Retrieve object "name" from Parse.com database for (ParseObject country : ob) { adapter.add((String) country.get("LikedFar")); } // Binds the Adapter to the ListView listview.setAdapter(adapter); // Close the progressdialog mProgressDialog.dismiss(); // Capture button clicks on ListView items setLV(); } 

    1 answer 1

    If I understand correctly, and the adapter is filled with data in this code

     for (ParseObject country : ob) { adapter.add((String) country.get("LikedFar")); } 

    then why not put a check on an empty value, like this:

     for (ParseObject country : ob) { String line = (String) country.get("LikedFar"); if(!line.isEmpty()) { adapter.add(line); } } 
    • now a few lines of the last (2) are cut off and become invisible, although the content is there. What could be the problem? (This is not my comment, the comment is contained in the edit from an anonymous user, the potential author of the question) - Timofei Bondarev