title: How to get last ListView item position using Custom Adapter class?
body: <p>Hi I am new for android in my app I have created a ListView using Custom Adapter class.</p>
  
  <p>In the ListView footer I have added two buttons like in the image bellowand when I tapped on ADDNEW button, I want to find ListView lost item position.</p>
  
  <h2>ListViewAdapter:-</h2>
  
  <pre><code>public class ListViewAdapter extends ArrayAdapter&lt;Friend&gt; {
  
      ViewHolder holder;
      private List&lt;Friend&gt; myFriends;
      private Activity activity;
  
      public ListViewAdapter(Activity context, int resource, List&lt;Friend&gt; objects) {
  
          super(context, resource, objects);
          this.activity = context;
          this.myFriends = objects;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
  
          // If holder not exist then locate all view from UI file.
          if (convertView == null) {
              // inflate UI from XML file
              convertView = inflater.inflate(R.layout.item_listview, parent, false);
              // get all UI view
              holder = new ViewHolder(convertView);
              // set tag for holder
              convertView.setTag(holder);
  
          } else {
              // if holder created, get tag from view
              holder = (ViewHolder) convertView.getTag();
          }
  
          holder.goButton.setTag(position);
  
          holder.binNumberEditText.setText(getItem(position).getBinNumberEditText());
          holder.qtyEditText.setText(getItem(position).getQtyEditText());
          holder.goButton.setOnClickListener(onConfirmListener());
  
          return convertView;
      }
  
       public void adding(String result){
  
              int position = ListViewadapter.getPosition();
  
              if (position != null &amp;&amp; !position.isEmpty() &amp;&amp; !position.equals("null")){
  
                  myFriends.add(new Friend("", ""));
                  notifyDataSetChanged();
  
              }else{
                  System.out.println("Yes there is null value");
              }
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SRCM1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SRCM1.png" alt="enter image description here"></a></p>