0

I have a button, which onClicked takes to another activity. Now I want the activity to open as bottomDialog. How o do that??

 if (success) {

                val intent = Intent(this, PaymentActivity::class.java)
                intent.putExtra("total_amount",totalAmount)
                startActivity(intent)
                finishAffinity()

              }

I want the PaymentActivity mentioned here to be opened as bottomSheet.

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
yazhini
  • 57
  • 1
  • 6
  • change ```PaymentActivity``` Theme in Manifest`````` this will working like activity as dialog – Elango Jul 15 '21 at 09:59
  • I get an error " java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity." – yazhini Jul 15 '21 at 10:04
  • check out this https://stackoverflow.com/a/35915764/12709358 – Elango Jul 15 '21 at 10:06
  • Extend your PaymentActivity from BottomSheetDialogFragment instead of AppCompatActivity. – dennisrufigill Jul 15 '21 at 10:11
  • Check this for bottom sheet dialog it may help you [Open BottomSheet](https://stackoverflow.com/questions/34243928/open-an-activity-or-fragment-with-bottom-sheet-deep-linking) – Dhananjay Waghela Jul 15 '21 at 10:19

1 Answers1

0

change your Payment Activity to BottomSheetDialogFragment

class PaymentActivity : BottomSheetDialogFragment() {

override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    return inflater.inflate(R.layout.activity_payment, container, false)
}

}

and you can call it like this,

if (success) {

           val b = PaymentActivity()
        b.show(supportFragmentManager, "Hi")

          }

Add total amount in Bundle.

dennisrufigill
  • 379
  • 1
  • 3
  • 14