title: Android-Get Background color of listview(item) programmatically
body: <p>First I create a background color for listview items like below,
  I have two custom listview like this:</p>
  
  <p><a href="https://i.stack.imgur.com/KlfLv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KlfLv.jpg" alt="enter image description here"></a></p>
  
  <p>My custom list for setting color:</p>
  
  <p>Code:</p>
  
  <pre><code>@Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          Holder holder = new Holder();
          final View rowView;
          rowView = inflater.inflate(R.layout.table_one, null);
          holder.tv = (TextView) rowView.findViewById(R.id.textView1);
          holder.tv.setText(result[position]);
          rowView.setBackgroundColor(Color.WHITE);
          rowView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  if (position == 0) {
                      rowView.setBackgroundColor(Color.BLUE);
                      MainActivity.counter = Color.BLUE;
                  } else if (position == 1) {
                      rowView.setBackgroundColor(Color.YELLOW);
                      MainActivity.counter = Color.YELLOW;
                  } else if (position == 2) {
                      rowView.setBackgroundColor(Color.GREEN);
                      MainActivity.counter = Color.GREEN;
                  } else if (position == 3) {
                      rowView.setBackgroundColor(Color.MAGENTA);
                      MainActivity.counter = Color.MAGENTA;
                  }
              }
          });
          return rowView;
      }
  </code></pre>
  
  <p>When user click on listview it changes to specifed color as above image, </p>
  
  <p>i need to get the color of listview saved in the list when click teh button.</p>
  
  <p>How can i do that, Need help pls</p>
  
  <p>In my MainActivity I have button , </p>
  
  <pre><code>check = (Button) findViewById(R.id.check);
   check.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  Toast.makeText(getApplicationContext(), "Checked", Toast.LENGTH_SHORT).show();
              }
          });
  </code></pre>