title: how to match string value in" if else" condition in android?
body: <p>here i am displaying 1 listview which is coming from server.if i click on any item  i want some alertbox to open...but for that i need match the condition eg.if listitem string matches with "Bianca pizza" then open alertbox else toast "hello"..here in my code its not taking listview item string .</p>
  
  <p>its weird its taking 1st value of listview item in toast (the code which i put before if condition just to check whether its correct or not.)but when i am comparing its not working.</p>
  
  <p>like in toast i m getting "Bianca pizza" but when i want to compare it with "Bianca Pizza" it should match and go inside the if condition but its not going inside and showing else condition.</p>
  
  <p>here is my code:</p>
  
  <pre><code>    public class SubMenu extends AppCompatActivity {
  
      JSONObject jsonobject;
      JSONArray jsonarray;
      ListView listview;
      ListViewAdapter adapter;
      ProgressDialog mProgressDialog;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist;
      static String RANK = "id";
      static String COUNTRY = "name";
      private ProgressDialog pDialog;
      String status="";
      static String FLAG = "image";
      Integer i = 1;
      String _stringVal;
  
  
  
  
  
      private static String url_create_book = "http://cloud....com/broccoli/creatinfo.php";
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          setContentView(R.layout.activity_sub_menu);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          String SelectedId = getIntent().getStringExtra("id");
  
  
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
  
          // Get the view from listview_main.xml
  
          // Execute DownloadJSON AsyncTask
          new DownloadJSON().execute();
      }
  
      // DownloadJSON AsyncTask
      private class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt; implements AdapterView.OnItemClickListener, AdapterView.OnItemSelectedListener {
  
          // @Override
          //  protected void onPreExecute() {
          //  super.onPreExecute();
          // Create a progressdialog
          //   mProgressDialog = new ProgressDialog(SubMenu.this);
          // Set progressdialog title
          //   mProgressDialog.setTitle("Categories of Main categories.....");
          // Set progressdialog message
          //  mProgressDialog.setMessage("Loading...");
          //  mProgressDialog.setIndeterminate(false);
          // Show progressdialog
          //  mProgressDialog.show();
          // }
  
          @Override
          protected Void doInBackground(Void... params) {
              // Create an array
              arraylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              // Retrieve JSON Objects from the given URL address
              jsonarray = JsonFunctions
                      .getJSONfromURL("http://cloud....com/broccoli/menu_typeitem.php?id=" + getIntent().getStringExtra("id"));
              try {
                  for (int i = 0; i &lt; jsonarray.length(); i++) {
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                      jsonobject = jsonarray.getJSONObject(i);
                      map.put("name", jsonobject.getString("name"));
                      map.put("image", jsonobject.getString("image"));
                      // Set the JSON Objects into the array
                      arraylist.add(map);
                  }
              } catch (JSONException e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void args) {
              // Locate the listview in listview_main.xml
              listview = (ListView) findViewById(R.id.list1);
              // Pass the results into ListViewAdapter.java
              adapter = new ListViewAdapter(SubMenu.this, arraylist);
              // Set the adapter to the ListView
              listview.setAdapter(adapter);
              listview.setOnItemClickListener(this);
  
          }
  
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                  int position, long rowId) {
  
              TextView name = (TextView) parent.findViewById(R.id.type1);
  
  
              Toast.makeText(SubMenu.this, "this is "+name.getText(), Toast.LENGTH_SHORT).show();
  
  
  
              if ( name.getText().toString().equalsIgnoreCase("Bian‌​‌​ca Pizza"))
              {
             //open alertbox
              }
               else{
  
                  Toast.makeText(SubMenu.this, "hello", Toast.LENGTH_SHORT).show();
  }
  </code></pre>
  
  <p>here is my listview adapter:</p>
  
  <pre><code>public class ListViewAdapter extends BaseAdapter {
  
      // Declare Variables
      Context context;
      LayoutInflater inflater;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
      ImageLoader imageLoader;
      HashMap&lt;String, String&gt; resultp = new HashMap&lt;String, String&gt;();
  
      public ListViewAdapter(Context context,
                             ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist) {
          this.context = context;
          data = arraylist;
          imageLoader = new ImageLoader(context);
      }
  
      @Override
      public int getCount() {
          return data.size();
      }
  
      @Override
      public Object getItem(int position) {
          return null;
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
      public View getView(final int position, View convertView, ViewGroup parent) {
          // Declare Variables
          TextView id;
          TextView name;
          TextView population;
          CircleImageView image;
  
          inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          View itemView = inflater.inflate(R.layout.list_item1, parent, false);
          // Get the position
          resultp = data.get(position);
  
          // Locate the TextViews in listview_item.xml
         // id = (TextView) itemView.findViewById(R.id.idq);
          name = (TextView) itemView.findViewById(R.id.type1);
  
  
          // Locate the ImageView in listview_item.xml
          image = (CircleImageView) itemView.findViewById(R.id.subimg);
        //  icon = (ImageView) itemView.findViewById(R.id.arrow);
          // Capture position and set results to the TextViews
        //  id.setText(resultp.get(SubMenu.RANK));
          name.setText(resultp.get(SubMenu.COUNTRY));
  
          // Capture position and set results to the ImageView
          // Passes flag images URL into ImageLoader.class
          imageLoader.DisplayImage(resultp.get(SubMenu.FLAG), image);
        //  imageLoader.DisplayImage(resultp.get(SubMenu.FLAG), icon);
          // Capture ListView item click
          /**itemView.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
          // Get the position
          resultp = data.get(position);
          Intent intent = new Intent(context, SingleItemView.class);
          // Pass all data rank
          intent.putExtra("rank", resultp.get(MainActivity.RANK));
          // Pass all data country
          intent.putExtra("country", resultp.get(MainActivity.COUNTRY));
          // Pass all data population
          intent.putExtra("population",resultp.get(MainActivity.POPULATION));
          // Pass all data flag
          intent.putExtra("flag", resultp.get(MainActivity.FLAG));
          // Start SingleItemView Class
          context.startActivity(intent);
  
          }
          });*/
          return itemView;
      }
  }
  </code></pre>