java - how to hide a nested layout after 5 seconds in android? -


i need hide nested layout after 5 seconds. layout code below,

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/invitation_single"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:divider="?android:dividervertical"     android:dividerpadding="5dp"     android:showdividers="middle"     tools:context=".mainactivity">      <imagebutton         android:id="@+id/image"         android:layout_width="50dp"         android:layout_height="50dp"         android:src="@drawable/ic_action_event" />      <linearlayout         android:layout_width="0dp"         android:layout_height="50dp"         android:layout_weight="1"         android:clickable="false"         android:focusable="true"         android:orientation="vertical">          <textview             android:id="@+id/invitation_title"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:paddingleft="5dp"             android:paddingright="0dp"             android:paddingtop="3dp"             android:textcolor="@color/black"             android:textsize="18sp" />          <textview             android:id="@+id/invitation_place"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:paddingleft="5dp"             android:paddingright="0dp"             android:textcolor="@color/black"             android:textsize="15sp" />     </linearlayout>      <linearlayout         android:id="@+id/hidden"         android:layout_width="0dp"         android:layout_height="50dp"         android:layout_marginleft="-270dp"         android:layout_margintop="60dp"         android:layout_weight="1"         android:clickable="true"         android:focusable="true"         android:orientation="horizontal"         android:paddingtop="1dp"         android:visibility="gone"         android:weightsum="3">           <button             android:id="@+id/yesbutton"             android:layout_width="30dp"             android:layout_height="30dp"             android:layout_marginleft="7dp"             android:layout_weight="1"             android:background="@color/blue"             android:text="yes"             android:textcolor="@color/black"></button>          <button             android:id="@+id/nobutton"             android:layout_width="30dp"             android:layout_height="30dp"             android:layout_marginleft="25dp"             android:layout_weight="1"             android:background="@color/blue"             android:text="no"             android:textcolor="@color/black"></button>          <button             android:id="@+id/buttonmaybe"             android:layout_width="30dp"             android:layout_height="30dp"             android:layout_marginleft="25dp"             android:layout_marginright="10dp"             android:layout_weight="1"             android:background="@color/blue"             android:text="maybe"             android:textcolor="@color/black"></button>      </linearlayout>   </linearlayout> 

my programming code below

    final linearlayout first = (linearlayout) convertview.findviewbyid(r.id.invitation_single);      final linearlayout second = (linearlayout) convertview.findviewbyid(r.id.hidden);   first.setonclicklistener(new view.onclicklistener() {                     @override                     public void onclick(view v) {                         switch (v.getid()) {                             case r.id.invitation_single:                                 //second.setvisibility(view.visible);                                 second.setvisibility(second.getvisibility() == view.visible ? view.gone : view.visible);                                 break;                          }                      } 

when onclick rootlayout(invitation_single) nestedlayout(hidden) visible below rootlayout.but need hide nestedlayout after 5 seconds onclick root layout.how can achieve ..

use thread.sleep()

case r.id.invitation_single:     try {         thread.sleep(5000);                 //1000 milliseconds = 1 second.     } catch(interruptedexception ex) {         thread.currentthread().interrupt();     }     // executed lines after 5 seconds delay goes here!     //second.setvisibility(view.visible);     second.setvisibility(second.getvisibility() == view.visible ? view.gone : view.visible);  break; 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -