In the code below the problem i m facing is that in onTouchListener method both if and else part is getting executed each time. Anyone have idea why is it happening like that? and aim of my project is on touch event on anywhere in on the webview the dock layout must appear on another touch it must disappear.Can anyone help regarding this?
Thanks in advance ..
public class MathiasdockActivity extends Activity {
/** Called when the activity is first created. */
RelativeLayout upperdock,parent;
LinearLayout tocbottom,tocparent;
boolean flag=true;
WebView wv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
parent=(RelativeLayout) findViewById(R.id.rl1);
upperdock=(RelativeLayout) findViewById(R.id.upperdock);
tocparent=(LinearLayout) findViewById(R.id.tocparent);
tocbottom=(LinearLayout) findViewById(R.id.linearLayout3);
upperdock.setVisibility(RelativeLayout.INVISIBLE);
tocparent.setVisibility(LinearLayout.INVISIBLE);
tocbottom.setVisibility(LinearLayout.INVISIBLE);
wv = (WebView) findViewById(R.id.webView1);
wv.loadUrl("file:///android_asset/hotspot/07-03.html");
wv.getSettings().setJavaScriptEnabled(true);
wv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(flag)
{
Toast toast1 = Toast.makeText(getBaseContext(), Boolean.toString(flag) + "if", 1000);
toast1.show();
upperdock.bringToFront();
tocparent.bringToFront();
tocbottom.bringToFront();
upperdock.setVisibility(RelativeLayout.VISIBLE);
tocparent.setVisibility(LinearLayout.VISIBLE);
tocbottom.setVisibility(LinearLayout.VISIBLE);
flag=false;
}
else
{
Toast toast2 = Toast.makeText(getBaseContext(), Boolean.toString(flag) + "else", 1000);
toast2.show();
wv.bringToFront();
upperdock.setVisibility(RelativeLayout.INVISIBLE);
tocparent.setVisibility(LinearLayout.INVISIBLE);
tocbottom.setVisibility(LinearLayout.INVISIBLE);
flag=true;
}
return flag;
}
});
}
}