title: compare listview time with currenttime
body: <p>There are 3 textviews and 1 button in my listview.One of textview contains time.I want button must get clicked after 20mins of intime.I want to compare Intime with current time and if difference >20 mins then button must get clicked.Following is my code-</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity  {
  
      TextView txtno,txtname,txtintime;
      ListView listView;
      ArrayList&lt;Model&gt; data;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          txtno=(TextView)findViewById(R.id.no);
          txtname=(TextView)findViewById(R.id.name);
          txtintime=(TextView)findViewById(R.id.intime);
  
          listView = (ListView) findViewById(R.id.list);
          data=new ArrayList&lt;&gt;();
  
          data.add(new Model(1,"ABC","11:45:50 AM"));
          data.add(new Model(2,"PQR","11:50:50 AM"));
          data.add(new Model(1,"XyZ","12:45:50 PM"));
          data.add(new Model(1,"SHjhsj","04:45:50 PM"));
  
          Custom c=new Custom(this,data);
          listView.setAdapter(c);
      }
  
  }
  </code></pre>
  
  <p><strong>Model.java</strong></p>
  
  <pre><code>public class Model {
  
      int no;
      String name,intime;
  
      public Model(int no, String name, String intime) {
          this.no = no;
          this.name = name;
          this.intime = intime;
      }
  
      public int getNo() {
          return no;
      }
  
      public void setNo(int no) {
          this.no = no;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getIntime() {
          return intime;
      }
  
      public void setIntime(String intime) {
          this.intime = intime;
      }
  }
  </code></pre>
  
  <p><strong>Custom.java</strong></p>
  
  <pre><code>public class Custom extends BaseAdapter {
      Activity a;
      ArrayList&lt;Model&gt; data;
  
      public Custom(Activity a, ArrayList&lt;Model&gt; data) {
          this.a = a;
          this.data = data;
      }
  
  
      @Override
      public int getCount() {
          return data.size();
      }
  
      @Override
      public Object getItem(int i) {
          return data.get(i);
      }
  
      @Override
      public long getItemId(int i) {
          return i;
      }
  
  
      public class Viewholder {
          TextView srno, name, intime;
          Button end;
      }
  
      @Override
      public View getView(final int i, View convertView, ViewGroup viewGroup) {
          Viewholder viewholder = null;
          if (convertView == null) {
              viewholder = new Viewholder();
              LayoutInflater li = a.getLayoutInflater();
              convertView = li.inflate(R.layout.list_item, viewGroup, false);
              viewholder.srno = (TextView) convertView.findViewById(R.id.cno);
              viewholder.name = (TextView) convertView.findViewById(R.id.cname);
              viewholder.intime = (TextView) convertView.findViewById(R.id.ctime);
              viewholder.end = (Button) convertView.findViewById(R.id.cend);
              convertView.setTag(viewholder);
          }else {
              viewholder=(Viewholder)convertView.getTag();
          }
  
          final Model model = data.get(i);
          viewholder.srno.setText(valueOf(data.get(i).getNo()));
          viewholder.name.setText(valueOf(data.get(i).getName()));
          viewholder.intime.setText(valueOf(data.get(i).getIntime()));
  
  
  
                  viewholder.end.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          Toast.makeText(a, data.get(i).getName()+" Exited", Toast.LENGTH_LONG).show();
                      }
                  });
  
  
  
          return convertView;
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      tools:context="com.example.abc.timer.MainActivity"&gt;
  
  
      &lt;TextView
          android:layout_width="70dp"
          android:layout_height="50dp"
          android:id="@+id/no"
          android:text="CustNo"
          android:textSize="20dp"
          android:textColor="#000"/&gt;
  
      &lt;TextView
          android:layout_width="80dp"
          android:layout_height="50dp"
          android:id="@+id/name"
          android:layout_toRightOf="@+id/no"
          android:text="Name"
          android:textSize="20dp"
          android:textColor="#000"/&gt;
  
      &lt;TextView
          android:layout_width="80dp"
          android:layout_height="50dp"
          android:id="@+id/intime"
          android:layout_toRightOf="@+id/name"
          android:text="InTime"
          android:textSize="20dp"
          android:textColor="#000"/&gt;
  
      &lt;TextView
          android:layout_width="70dp"
          android:layout_height="50dp"
          android:id="@+id/exit"
          android:text="Exit"
          android:layout_toRightOf="@+id/intime"
          android:textSize="20dp"
          android:textColor="#000"/&gt;
  
      &lt;ListView
          android:layout_width="match_parent"
          android:layout_height="400dp"
          android:layout_below="@+id/no"
          android:id="@+id/list"
          &gt;&lt;/ListView&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>list_item.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  
      &lt;TextView
          android:layout_width="70dp"
          android:layout_height="match_parent"
          android:id="@+id/cno"
          android:gravity="center"/&gt;
  
      &lt;TextView
          android:layout_width="70dp"
          android:layout_height="match_parent"
          android:id="@+id/cname"
          android:gravity="center"/&gt;
  
      &lt;TextView
          android:layout_width="80dp"
          android:layout_height="match_parent"
          android:id="@+id/ctime"
          android:gravity="center"/&gt;
  
    &lt;Button
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:text="End"
        android:id="@+id/cend"
        android:background="#c14c4a"
        android:gravity="center"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>