-
-
Save Ayesha17/7f5ed742b4684ff558b980055f629d8b to your computer and use it in GitHub Desktop.
BottomSheetDialog example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Button button = (Button) findViewById(R.id.button); | |
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
openDialog(); | |
} | |
}); | |
} | |
private void openDialog() { | |
View view = getLayoutInflater().inflate(R.layout.sheet_main, null); | |
dialog = new BottomSheetDialog(this); | |
dialog.setContentView(view); | |
TextView camera_sel = (TextView) view.findViewById(R.id.camera); | |
TextView gallery_sel = (TextView) view.findViewById(R.id.gallery); | |
camera_sel.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
takePhotoFromCamera(); | |
dialog.dismiss(); | |
} | |
}); | |
gallery_sel.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
takePhotoFromGallery(); | |
dialog.dismiss(); | |
} | |
}); | |
dialog.show(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="horizontal" | |
android:padding="4dp"> | |
<TextView | |
android:id="@+id/camera" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:background="?attr/selectableItemBackgroundBorderless" | |
android:clickable="true" | |
android:drawablePadding="8dp" | |
android:drawableTop="@drawable/ic_camera" | |
android:gravity="center_horizontal" | |
android:padding="16dp" | |
android:text="Camera" | |
android:textSize="18sp" /> | |
<TextView | |
android:id="@+id/gallery" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:background="?attr/selectableItemBackgroundBorderless" | |
android:clickable="true" | |
android:drawablePadding="8dp" | |
android:drawableTop="@drawable/ic_panorama" | |
android:gravity="center_horizontal" | |
android:padding="16dp" | |
android:text="Gallery" | |
android:textSize="18sp" /> | |
</LinearLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment