Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 953255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:01:31+00:00 2026-05-16T00:01:31+00:00

I defined a dialog the following way: public void displayAvailableDevices(Vector<UserDevice> availableDevices) { connector.setDevicesFound(true); UserDevice[]

  • 0

I defined a dialog the following way:

public void displayAvailableDevices(Vector<UserDevice> availableDevices) {

        connector.setDevicesFound(true);
        UserDevice[] devices = new UserDevice[availableDevices.size()];

        for (int i = 0; i < availableDevices.size(); i++) {
            devices[i] = availableDevices.elementAt(i);
        }

        Arrays.sort(devices);

        Vector<UserDevice> sorted = new Vector<UserDevice>();
        for (int j = 0; j < devices.length; j++) {
            sorted.add(devices[j]);
        }

        allAvailableDevices = sorted;

        connector.stopNeighbourDiscovery();
        if (dialog != null) {
            dialog.dismiss();
            checkedUser = null;
        }
        dialog = new Dialog(this);
        dialog.setContentView(R.layout.available_users);
        dialog.setTitle("Available Devices");

        RelativeLayout rootLayer = (RelativeLayout) dialog.findViewById(R.id.dialogRoot);
        rootLayer.setBackgroundColor(Color.WHITE);

        ListView userTable = (ListView) dialog.findViewById(R.id.userList);
        adapter = new UserAdapter();
        userTable.setAdapter(adapter);
        userTable.setOnItemClickListener(new UserListener());

        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm); 

        connect = (Button) dialog.findViewById(R.id.userList_connect);
        connect.setMinWidth(dm.widthPixels / 2);
        connect.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (checkedUser != null) {
                    dialog.dismiss();
                    connector.connectToDevice(checkedUser);
                }
            }

        });

        Button start = (Button) dialog.findViewById(R.id.userList_start);
        start.setMinWidth(dm.widthPixels / 2);
        start.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
                startProfileView(); 
            }

        });

        Button refresh = (Button) dialog.findViewById(R.id.userList_refresh);
        refresh.setMinWidth(dm.widthPixels / 2);
        refresh.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
                getGameBaseLayer().resetAvailableUserDevices();
                connector.refresh();
            }

        });

        Button cancel = (Button) dialog.findViewById(R.id.userList_cancel);
        cancel.setMinWidth(dm.widthPixels / 2);
        cancel.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }

        });

        dialog.show();
        if (checkedUser == null) {
            connect.setEnabled(false);
        }

    }

If this dialog is displayed and the user presses the back button, the dialog is dismissed. However I would like to do some further processing, but how can i detect if the user has pressed the back button?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:01:31+00:00Added an answer on May 16, 2026 at 12:01 am

    I’m quite positive that this article can help a lot. As far as I understand, pressing ‘BACK’ is like cancelling the dialog (like pressing ‘CANCEL’). They show how to make a dialog uncancelable and how to implement a listener to catch the ‘cancel’ events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined a new dialog and its controls in an already existing resource
Is there a way to export the settings defined in Window > Preferences Dialog
ive defined the following and filled it with elements: vector <vector<double> > my_vector; but
I have a very simple dialog defined as: import android.app.AlertDialog; import android.content.Context; import android.view.LayoutInflater;
I have created a dialog with the JQuery dialog plugin. My dialog is defined
For learning jQuery UI dialog, I have the code defined below. I need to
In the imageviewer example, QPainter and QPrintDialog objects are defined and used as following:
How to position the primefaces dialog dynamically at x,y co-ordinates defined by javascript variables
hi I am using following code to pop up Facebook application request dialog in
Consider the following class DialgBean.java, which defines the properties of a dialog box on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.