title: Issue with Onclick listener inside OnItemClick listener
body: <p>There are very nice explanations about the OnItemclicklistener in google,but still I couldn't solve my issue.
  I need to delete the items listview ,when I click any item in listview,a custom dialog box will popup with delete button and update button,when I click that delete button,It's need to delete that particular item in the listview.But now I'm getting exception on Delete button click.Please help me to solve this out.</p>
  
  <pre><code>rldlist3.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(final AdapterView&lt;?&gt; arg0, View arg1, final int position, long arg3) {
  
                  // custom dialog
                  final Dialog dialog = new Dialog(context);
                  dialog.setContentView(R.layout.custom);
                  dialog.setTitle("Manage Expenses");
  
                  // set the custom dialog components
  
                  Button up = (Button) dialog.findViewById(R.id.Update);
                  Button del= (Button) dialog.findViewById(R.id.Delete);
                  // if button is clicked, close the custom dialog
                  up.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          dialog.dismiss();
                      }
                  });
                  del.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
  
                          Expence row = (Expence) arg0.getItemAtPosition(position);
                          selected_id = row.getE_id();
                         System.out.println(selected_id);
  
                          db = helper.getWritableDatabase();
                          db.delete(DBhelper.TABLE3, DBhelper.ID1 + "=?", new String[]{selected_id});
                          db.close();
  
                          fetchData3();
                          Toast.makeText(List_activity.this, "successfully deleted", Toast.LENGTH_LONG).show();
  
  
                      }
                  });
  
                  dialog.show();
  
              }
  
          });
  </code></pre>
  
  <blockquote>
    <p>10-27 09:07:16.926    1915-1915/com.example.username.weddingplanning
    E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.example.username.weddingplanning, PID: 1915
        java.lang.ClassCastException: android.database.sqlite.SQLiteCursor cannot be cast to com.example.username.weddingplanning.Expence
                at com.example.username.weddingplanning.List_activity$1$2.onClick(List_activity.java:73)
                at android.view.View.performClick(View.java:4756)
                at android.view.View$PerformClick.run(View.java:19749)
                at android.os.Handler.handleCallback(Handler.java:739)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5221)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)</p>
  </blockquote>
  
  <p>My expense java class</p>
  
  <pre><code>public class Expence {
      private String category;
      private String description;
      private String amount;
      private String date;
      private String status;
      private String year;
      private String month;
  
      public Expence(String e_id) {
          this.e_id = e_id;
      }
  
      private String e_id;
  
      public String getE_id() {
          return e_id;
      }
  
      public void setE_id(String e_id) {
          this.e_id = e_id;
      }
      //get methods to access these variables
      public String getCategory() {
          return category;
      }
  
      //set methods to modify them
      public void setCategory(String category) {
          this.category = category;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getAmount() {
          return amount;
      }
  
      public void setAmount(String amount) {
          this.amount = amount;
      }
  
      public String getDate() {
          return date;
      }
  
      public void setDate(String date) {
          this.date = date;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  
  
      public String getYear() {
          return year;
      }
  
      public void setYear(String year) {
          this.year = year;
      }
  
      public String getMonth() {
          return month;
      }
  
      public void setMonth(String month) {
          this.month = month;
      }
  }
  </code></pre>