I use the backend in the backendless. The ListView adapter has a View method responsible for inserting text into the field.

  public View getView(int position, View convertView, ViewGroup parent ) { View view = convertView == null ? mInflater.inflate( mResource, parent, false ) : convertView; TextView restaurantNameView = (TextView) view.findViewById( R.id.restaurantName ); TextView cuisineView = (TextView) view.findViewById( R.id.restaurantCuisine ); TextView locationsNumberView = (TextView) view.findViewById( R.id.restaurantLocations ); Restaurant item = getItem( position ); restaurantNameView.setText( item.getName() ); cuisineView.setText( item.getCuisine() ); String locationsNumberTextTemplate = getContext().getResources().getQuantityString( R.plurals.restaurant_locations, item.getLocations().size() ); locationsNumberView.setText( String.format( locationsNumberTextTemplate, item.getLocations().size() ) ); return view; } 

from this code I can not understand these lines you would help me a lot

  String locationsNumberTextTemplate = getContext().getResources().getQuantityString( R.plurals.restaurant_locations, item.getLocations().size() ); locationsNumberView.setText( String.format( locationsNumberTextTemplate, item.getLocations().size() ) ); 

if they said what for he and for what purpose

1 answer 1

Check whether the getContext () method exists in the class (or in the class interface) with this method.

  • I understand what you are about locationsNumberView.setText (String.format (locationsNumberTextTemplate, item.getLocations (). size ())); - elik
  • He gives the number from the database - elik
  • String locationsNumberTextTemplate = getContext (). GetResources (). GetQuantityString (R.plurals.restaurant_locations, item.getLocations (). Size ()) - elik
  • that's actually why this method is what it does ???? - elik
  • one
    Although I could be wrong, I didn’t get in touch with java - Vasily Medvedev