title: on button click automatically remove selected spinner item
body: <p>I have a spinner that show my array data list and delete button.
  What I am trying to do is when I click on the delete button, it automatically deletes a selected spinner value, but I'm not certain how to do this.</p>
  
  <p>In the delete button click function, deleted the selected spinner value after debugging my activity again but I want delete automatically a selected spinner value when I click on the delete button.</p>
  
  <pre><code>package quesansw.the1;
  
  import java.util.ArrayList;
  import android.app.Activity;
  import android.app.Dialog;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.net.NetworkInfo.State;
  import android.os.Bundle;
  import android.view.View;
  import android.view.Window;
  import android.view.WindowManager;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Spinner;
  import android.widget.AdapterView.OnItemSelectedListener;
  
  public class View1 extends Activity { 
      SQLiteDatabase db;
      ArrayAdapter adapter; 
      private String array_spinner[];
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          db = openOrCreateDatabase("mydatabase.db",
                  SQLiteDatabase.CREATE_IF_NECESSARY, null);
  
          final Dialog d1 = new Dialog(this);
          Window window = d1.getWindow();
          window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                  WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  
          //d1.setTitle("Login");
  
          d1.setContentView(R.layout.view);
          d1.show();
          Button Click = (Button) d1.findViewById(R.id.Click);
          Button Save = (Button) d1.findViewById(R.id.Save);
          Button Delete = (Button) d1.findViewById(R.id.Delete);
  
          ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
          Cursor cursor = db.rawQuery("select * from records", null);
          list.add("");
          if (cursor.moveToFirst())
          {
              do
              {
                  list.add(cursor.getString(0));
              }
              while (cursor.moveToNext());
          }
  
          /*array_spinner=new String[20];
          array_spinner[0]=list.get(0);*/
          Spinner s = (Spinner) d1.findViewById(R.id.tittle_spinner);
          adapter = new ArrayAdapter&lt;Object&gt;(this,android.R.layout.simple_spinner_item, list.toArray());
  
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          s.setAdapter(adapter);
  
  
          /*Save.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
  
                  Spinner s = (Spinner) d1.findViewById(R.id.tittle_spinner);
                  String str = s.getSelectedItem().toString();
                  System.out.println("********"+str);
                  Cursor cur1=db.rawQuery("select * from records where tittle='"+str+"' ",null);
                  cur1.moveToNext();
                  String str1=cur1.getString(1);
  
                  EditText ans = (EditText) d1.findViewById(R.id.text);
                  ans.setText(str1);
  
              }
              });*/
  
          Delete.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
  
                  Spinner s = (Spinner) d1.findViewById(R.id.tittle_spinner);
                  String str = s.getSelectedItem().toString();
                  db.execSQL("delete from records where tittle='"+str+"' ");
  
              }
              });
  
  
          Click.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
  
                  Spinner s = (Spinner) d1.findViewById(R.id.tittle_spinner);
                  String str = s.getSelectedItem().toString();
                  System.out.println("********"+str);
                  Cursor cur1=db.rawQuery("select * from records where tittle='"+str+"' ",null);
                  cur1.moveToNext();
                  String str1=cur1.getString(1);
  
                  EditText ans = (EditText) d1.findViewById(R.id.text);
                  ans.setText(str1);
  
  
              }
              });
      }
  }
  </code></pre>
  
  <p>1) Here is my activity screen shot</p>
  
  <p><img src="https://i.stack.imgur.com/6g57Q.jpg" alt="Activity Screen Shot"></p>
  
  <p>2) Another screen shot with spinner values:</p>
  
  <p><img src="https://i.stack.imgur.com/czOdr.jpg" alt="Spinner Values"></p>