So I am trying to delay the textview (tvMessage3) 2 times in my code when the button is pressed, but it doesn't work. Therefore all I see is "exiting good bye" text but not "Dog Found" text. Also I am unable to change the button text, once it is clicked. Any suggestions? Plus no errors in logcat.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/surface_camera" />
<teaonly.droideye.OverlayView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:id="@+id/surface_overlay"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/layout_setup"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center|bottom"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center"
android:background="#88333333"
android:orientation="vertical">
<TextView
android:id="@+id/tv_message2"
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "5dip"
android:layout_marginRight = "5dip"
android:gravity="center"
android:textColor="#FFFFFFFF"
android:textSize="24dip"/>
</LinearLayout>
<TextView
android:id="@+id/tv_message1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:gravity="center"
android:textColor="#FFFFFFFF"
android:textSize="24dip" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center"
android:background="#88333333"
android:orientation="horizontal">
<!--
<Button
android:id="@+id/btn_setup"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin = "8dip"
android:textSize="24dip"
android:textStyle="bold"
android:text="@string/action_setup"/>
-->
<Button
android:id="@+id/btn_exit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin = "8dip"
android:textSize="24dip"
android:textStyle="bold"
android:text="@string/action_exit"/>
<TextView
android:id="@+id/tv_message3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="9dip"
android:layout_marginRight="9dip"
android:gravity="center"
android:textColor="#FFFFFFFF"
android:textSize="25dip" />
</LinearLayout>
</LinearLayout>
<!-- <TextView
android:id="@+id/tvLocation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:gravity="top|left"
android:textColor="#FFFFFFFF"
android:textSize="24dip" /> -->
</FrameLayout>
</FrameLayout>
Here is my src file:
public void onButtonPress() {
btnExit.setText("Recognizing ...");
tvMessage1.setVisibility(View.GONE);
btnExit.setVisibility(View.GONE);
tvMessage3 = (TextView)findViewById(R.id.tv_message3);
tvMessage3.setTextColor(Color.RED);
tvMessage3.setText("Recognizing ........");
try{
Thread.sleep(5000);
}catch(InterruptedException ex){
ex.printStackTrace();
}
tvMessage3.setTextColor(Color.GREEN);
tvMessage3.setText("Dog Found");
android.os.SystemClock.sleep(5000);
tvMessage3.setText("exiting good bye");
}
private OnClickListener exitAction = new OnClickListener() {
@Override
public void onClick(View v) {
onButtonPress();
onPause();
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
//setup adView
LinearLayout layout = (LinearLayout)findViewById(R.id.layout_setup);
adView = new AdView(this, AdSize.BANNER, "a1507f940fc****");
layout.addView(adView);
adView.loadAd(new AdRequest());
btnExit = (Button)findViewById(R.id.btn_exit);
btnExit.setVisibility(1);
btnExit.setOnClickListener(exitAction);
tvMessage1 = (TextView)findViewById(R.id.tv_message1);
tvMessage2 = (TextView)findViewById(R.id.tv_message2);