Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – How to implement interfaces for dialog created from android binding from a XML?

Posted on November 11, 2022 By

Solution 1 :

Before setting the view to dialog, create a variable view and initialize it with dialogVolumeAllBinding.root which returns the root view.

View root = dialogVolumeAllBinding.root;

Now you can implement onTouchListener or any other interface on this root view.

root.setOnTouchListener(new OnTouchListener(){
// your code
});

Problem :

I have an Android binding for a XML called dialog_volume_all.xml which is a layout. So its binding is called DialogVolumeAllBinding. I’m inflating it like this:

DialogVolumeAllBinding dialogVolumeAllBinding = DialogVolumeAllBinding.inflate(LayoutInflater.from(MainActivity.this));

and I’m creating a dialog from it as

AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.MyDialogTheme);
AlertDialog alert = builder.create();
alert.setView(dialogVolumeAllBinding);

However I also want to implement public boolean onTouchEvent(MotionEvent event) { on my dialog.

How can I implement things on a dialog from a binding?

READ  [FIXED] android - How to align text in recyclerview for every element in the row?
Powered by Inline Related Posts
Android Tags:android, android-layout, java

Post navigation

Previous Post: [FIXED] java – How can I solve this Android Studio Firebase problem?
Next Post: [FIXED] Android Java Publish result cast issue at MyCustomAdapter.java

Related Posts

[FIXED] java – How to format the text of a Snackbar in Android Android
[FIXED] android – Kotlin App Crash if back button pressed during fetching API Android
[FIXED] android – Why i can’t post data from signUp form to firebase Android
[FIXED] gps – How Do I Change The Update Frequency Of The HERE Android SDK PositioningManager? Android
[FIXED] Android Studio 3.6.3 not showing suggestions in XML Android
[FIXED] java – textviewArray[i].setText(stringArray[i]); is null Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme