I have one imageButton. When I clicked on ImageButton. It makes VISIBLE another layout(childLayout) at top of the Parent Layout android:id="@+id/mainLayout".Now ChildLayout have three buttons (Back, Call, Web). I implemented OnClickListeners for Back, Call & Web buttons.But when i clicked on "back" button it not fired event. But when i double click on buttons OnClickListener worked. Why OnClickListener not worked at single click.?
@Override
public void onSingleTapConfirmed() {
childLayout = (LinearLayout) findViewById(R.id.childView);
childLayout.setVisibility(View.VISIBLE);
backButton = (Button)findViewById(R.id.back);
web = (ImageButton) findViewById(R.id.web);
call = (ImageButton) findViewById(R.id.call);
backButton.setOnClickListener(backButtonListener);
call.setOnClickListener(callListener);
web.setOnClickListener(webListener);
}
OnClickListener callListener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:415-817-9955,’10"));
startActivity(callIntent);
}
};
OnClickListener webListener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent web = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.parse("http://google.com");
web.setData(u);
startActivity(web);
}
};
OnClickListener backButtonListener = new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
};
and my xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/childView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/nav_bar"
android:padding="5dp"
android:visibility="gone" >
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/title_btn"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Business"
android:textColor="@color/white" >
</Button>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Image"
android:textStyle="bold" />
<ImageButton
android:id="@+id/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/phone" />
<ImageButton
android:id="@+id/web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/web" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>
or i should have to use other method to show child layout on Single Tap event of imageButton. Thanks in advance.