title: Android dialog not showing
body: <p>Who would of thought getting a dialog box to show would be so difficult. In C# it is so easy. I've looked all over line for help and every tip seems to cause me trouble than good. Can someone please look at the below code and tell me where I might have gone wrong?</p>
  
  <p>What I want is very simple. User clicks button. Then list appears. Then user clicks on one of the items in list, and dialogue appears. The code in onItemClick in the listview event is from someone else. It apparently works for that person. I keep clicking and seeing nothing. I'm open to suggestions on how to fix it, or new code all together. Sorry, the log has no error messages. </p>
  
  <p>Please be specific about where I put the code as I'm an Android noob. And thank you in advance!</p>
  
  <pre><code>public class SetPrediction extends Activity
  {
      Button btnInsrt, btnFTeam, btnSTeam;
      ArrayList&lt;NameValuePair&gt; nameValuePairs;
      TextView txtGameTeams;
      Bundle recdData;
      String game;
  
      JSONArray jArray;
      String result;
      InputStream is;
      StringBuilder sb;
  
      ArrayList&lt;String&gt; fNames;
      ListView listView;
  
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.set_prediction);
  
          nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
          txtGameTeams = (TextView) findViewById(R.id.txtGameTeams);
  
          recdData = getIntent().getExtras(); 
          game = recdData.getString("xxxx.xxxx.xxx");
          txtGameTeams.setText("xxxxxxx: " + game + " game.");
  
          btnInsrt = (Button) findViewById(R.id.btnInsert);
          btnFTeam = (Button) findViewById(R.id.btnFirstTeam);
          btnSTeam = (Button) findViewById(R.id.btnSecondTeam);
  
          btnFTeam.setText(removeSpaces(game.split("vs")[0]));
          btnSTeam.setText(removeSpaces(game.split("vs")[1]));
  
          btnSTeam.setOnClickListener(new View.OnClickListener() 
          {
              public void onClick(View v) 
              {
                  String result = "";
                  ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                  nameValuePairs.add(new BasicNameValuePair("players", removeSpaces(game.split("vs")[1])));
  
                  fNames = new ArrayList&lt;String&gt;();
                  listView = (ListView) findViewById(R.id.lstPlayerForPrediction);
  
                  //http post
                  try
                  {
                      HttpClient httpclient = new DefaultHttpClient();
                      HttpPost httppost = new HttpPost("http://xxxxx/getTeamPlayers.php");
                      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                      HttpResponse response = httpclient.execute(httppost); 
                      HttpEntity entity = response.getEntity();
                      InputStream is = entity.getContent();
  
                      BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                      StringBuilder sb = new StringBuilder();
                      String line = null;
                      while ((line = reader.readLine()) != null) 
                      {
                          sb.append(line + "\n");
                      }
                      is.close();
  
                      result=sb.toString();
                  }
                  catch(Exception e)
                  {
                      Log.e("log_tag", "Error in http connection " + e.toString());
                  }
  
                  //parse json data
                  try
                  {
                      JSONArray jArray = new JSONArray(result);
                      for(int i=0;i&lt;jArray.length();i++)
                          fNames.add(jArray.getJSONObject(i).getString("First_Name"));  
  
                  }
                  catch(JSONException e)
                  {
                      Log.e("log_tag", "Error parsing data " + e.toString());
                  }
  
                  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(SetPrediction.this, android.R.layout.simple_list_item_1, fNames);
                  listView.setAdapter(adapter);
  
                  listView.setOnItemClickListener(new OnItemClickListener()
                  {
                      public void onItemClick(AdapterView&lt;?&gt; arg0, View predictView, int item, long arg3) 
                      {
                          final CharSequence[] items = {"Online", "Away", "Do not distrub","Invisible","Offline"}; 
                          AlertDialog.Builder builder = new AlertDialog.Builder(SetPrediction.this); 
  
  
                          builder.setTitle("Change Status"); 
                          builder.setItems(items, new DialogInterface.OnClickListener() 
                          { 
                              public void onClick(DialogInterface dialog, int item) 
                              { 
                                  Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); 
                              } 
                          });
  
                          AlertDialog alert = builder.create(); 
                          alert.show();
                      } 
                  });
              }
          });
      }
  
  
      public String removeSpaces(String s) 
      {  
          StringTokenizer st = new StringTokenizer(s," ",false);
          String t="";
          while (st.hasMoreElements()) t += st.nextElement();
          return t;
      }
  </code></pre>
  
  <p>The problem is in the <code>listView.setOnItemClickListener(new OnItemClickListener()</code> event. That the part that doesn't work.</p>