title: Alert dialog in listview from selected item
body: <p>I am having some problems with an alertdialog box. I have a listview containing some strings and when i click the box, it shows an alert dialog box giving the option to book or cancel (its a taxi app). I am trying to get it so the name of the item chosen shows in the alert dialog box. But everytime i try it comes up showing random letters and numbers. Ill post my code as it might make it easier to understand:</p>
  
  <p>Code below -</p>
  
  <pre><code>public class TaxiMain extends ListActivity {
  /** Called when the activity is first created. 
   * @return */
  
  class Taxi {
      private String taxiName;
      private String taxiAddress;
  
      public String getName() {
          return taxiName;
      }
  
      public void setName(String name) {
          taxiName = name;
      }
  
      public String getAddress() {
          return taxiAddress;
      }
  
      public void setAddress(String address) {
          taxiAddress = address;
      }
  
      public Taxi(String name, String address) {
          taxiName = name;
          taxiAddress = address;
      }
  }
  
  public class TaxiAdapter extends ArrayAdapter&lt;Taxi&gt; {
      private ArrayList&lt;Taxi&gt; items;
      private TaxiViewHolder taxiHolder;
  
      private class TaxiViewHolder {
          TextView name;
          TextView address; 
      }
  
      public TaxiAdapter(Context context, int tvResId, ArrayList&lt;Taxi&gt; items) {
          super(context, tvResId, items);
          this.items = items;
      }
  
      @Override
      public View getView(int pos, View convertView, ViewGroup parent) {
          View v = convertView;
          if (v == null) {
              LayoutInflater vi = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
              v = vi.inflate(R.layout.taxi_list_item, null);
              taxiHolder = new TaxiViewHolder();
              taxiHolder.name = (TextView)v.findViewById(R.id.taxi_name);
              taxiHolder.address = (TextView)v.findViewById(R.id.taxi_address);
              v.setTag(taxiHolder);
          } else taxiHolder = (TaxiViewHolder)v.getTag(); 
  
          Taxi taxi = items.get(pos);
  
          if (taxi != null) {
              taxiHolder.name.setText(taxi.getName());
              taxiHolder.address.setText(taxi.getAddress());
          }
  
          return v;
      }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      final String[] taxiNames = getResources().getStringArray(R.array.taxi_name_array);
      final String[] taxiAddresses = getResources().getStringArray(R.array.taxi_address_array);
  
      ArrayList&lt;Taxi&gt; taxiList = new ArrayList&lt;Taxi&gt;();
  
      for (int i = 0; i &lt; taxiNames.length; i++) {
          taxiList.add(new Taxi(taxiNames[i], taxiAddresses[i]));
      }
  
      setListAdapter(new TaxiAdapter(this, R.layout.taxi_list_item, taxiList));  
  
      final ListView lv = getListView();
      lv.setTextFilterEnabled(true);
  
          lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; a, View v, final int position, long id)
          {   
  
              final int selectedPosition = position;
              AlertDialog.Builder adb=new AlertDialog.Builder(TaxiMain.this); 
               adb.setTitle("Taxi Booking");
               adb.setMessage("You Have Selected: "+taxiNames); 
               adb.setPositiveButton("Book", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       Intent intent = new Intent(TaxiMain.this, Booking.class);
                       intent.putExtra("booking",  taxiNames[selectedPosition]);
                       intent.putExtra("address",  taxiAddresses[selectedPosition]);
                       startActivity(intent);
                   }
               });
               adb.setNegativeButton("Cancel", null); 
               adb.show();
           }
       });
  </code></pre>
  
  <p>You'll see at the bottom of the code, theres the line that wont work properly. - </p>
  
  <pre><code>adb.setMessage("You Have Selected: "+taxiNames);
  </code></pre>
  
  <p>If anyone can help into seeing why this wont show would be of great help.</p>
  
  <p>Thanks</p>