title: Error in showing alert dialog while clicking on a list view item
body: <p>Error in showing alert dialog while clicking on a list view item.</p>
  
  <p>The code is given below.. this is a program  done in android sqlite.The data retrieved is shown in the list view   but the alert dialogue does not working properly for edit and delete.</p>
  
  <p>please help me with the code......</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.ArrayList;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.PopupWindow;
  
  public class Display11 extends Activity {
      ListView listview;
      PopupWindow popup;
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.display1);
  
          listview=(ListView)findViewById(R.id.listView1);
          Intent in=getIntent();
          ArrayList&lt;String&gt; a=in.getStringArrayListExtra("Key");
          ArrayAdapter&lt;String&gt; dis=new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,a);
          listview.setAdapter(dis);
          listview.setTextFilterEnabled(true);
          listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long rowId) {
                  // TODO Auto-generated method stub
  
          ///public void OnItemClick(AdapterView&lt;?&gt; parent, View view, int position,long rowId){
                  int itemposition = position;
                  String itemValue = (String)listview.getItemAtPosition(position); 
                  // TODO Auto-generated method stub
  
  
  
                  AlertDialog.Builder alert  = new AlertDialog.Builder(getApplicationContext());
                  /*LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
                  View view1 =inflater.inflate(R.layout.alert_dialog,null);
                  alert.setView(view1);*/
                  //ad.setView(inflater.inflate(R.layout.alert_dialog, null));
                  popup = new PopupWindow(getBaseContext());
                  //popup.setContentView(alert_)
                  alert.setMessage("Database Manager");
  
                  alert.setIcon(R.drawable.ic_launcher);
                  alert.setTitle("Terms of Service");
  
                  alert.setPositiveButton("edit",new DialogInterface.OnClickListener(){
  
                      public void onClick(DialogInterface arg0, int arg1) {
                          // TODO Auto-generated method stub
                          Intent positiveActivity=new Intent(getApplicationContext(),com.cerebtec.contactdb.PositiveActivity.class);
                      startActivity(positiveActivity);
                      }});
  
                  alert.setNegativeButton("delete",new DialogInterface.OnClickListener(){
  
                      public void onClick(DialogInterface dialog, int which) {
                          // TODO Auto-generated method stub
                          Intent negativeActivity=new Intent(getApplicationContext(),com.cerebtec.contactdb.NegativeActivity.class);
                      startActivity(negativeActivity);
                      }});
                  //ad.setNeutralButton("Cancel",null);
                  //ad.setCancelable(false);
  
  
                  //AlertDialog alert=ad.create();
                  //alert.setView(view1);
                  alert.create();
                  alert.show();
              }});
          }}
  </code></pre>