How to dismiss the single select dialog in AlertDialog

by mercury xu » Sun, 15 Mar 2009 13:13:01 GMT


Sponsored Links
 i Vincent

That a good idea , as we know, if we build an alterDlg need following
code

//modify by mercury xu 20090314 in the new sdk
//they don't support this function as showAlert!

new AlertDialog.Builder(loginScreen.this)
.setTitle("Login Data")
.setMessage("Login :" + usrTxt + "\n"+ "PassWords : " + pwdTxt)
.setIcon(R.drawable.icon)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
setResult(RESULT_OK);
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
})
.show();

maybe you can try to change the setPositiveButton and setNegativeButton
as Not visible or comment them, and add following code for keyup or keydown
founction.

OnClickListener as setResult(RESULT_OK);
finish();

you can get some useful infomation from
http://developer.android.com/reference/android/app/AlertDialog.html.

boolean
onKeyDown<http://developer.android.com/reference/android/app/AlertDialog.html#onKeyDown%28int,%20android.view.KeyEvent%29>(int
keyCode,
KeyEvent<http://developer.android.com/reference/android/view/KeyEvent.html>event)
A
key was pressed down.
boolean
onKeyUp<http://developer.android.com/reference/android/app/AlertDialog.html#onKeyUp%28int,%20android.view.KeyEvent%29>(int
keyCode,
KeyEvent<http://developer.android.com/reference/android/view/KeyEvent.html>event)
A
key was released.

those two founction I hope that is your need.

Wish good luck and best regards!

Mercury







2009/3/15 vincent Kor <kor.vinc...@gmail.com>


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. LayoutInflater did not apply android:layout_width and android:layout_height defined in XML

The layout that I defined are as following

-----------------------------
button.xml-----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Button
        xmlns:android="http://schemas.android.com/apk/res/android"
        style="@style/Theme.Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
/>
---------------------------------------------------------------------------------------------

----------------------------------main.xml----------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        xmlns:iii="http://schemas.android.com/apk/res/
org.iii.application.sis"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
       >


        <ScrollView
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="1"
        >
                <LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"

                  android:orientation="horizontal">

                        <LinearLayout
                                android:orientation="vertical"
                                android:layout_width="wrap_content"
                                android:layout_height="fill_parent"
                                android:paddingLeft="20px"
                                android:id="@+id/left_cat"
                        />
                         <LinearLayout
                                android:orientation="vertical"
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:gravity="right"
                                android:paddingRight="20px"
                                android:id="@+id/right_cat"
                         >

                         </LinearLayout>
                </LinearLayout>
        </ScrollView>


        <com.ngu.android.view.BottomPanel
                android:layout_weight="5"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
        />

</LinearLayout>
--------------------------------------------------------------------------------------------------------------------------------------


when I tried to add button dynamically in right_cat,

LayoutInflater layoutInflater = LayoutInflater.from(this);
LinearLayout rightLayout =
(LinearLayout)this.findViewById(R.id.right_cat);

Button button_BIO_Record_Table =
(Button)layoutInflater.inflate(R.layout.button, null);
button_BIO_Record_Table.setText(R.string.button_BIO_Record_Table);
rightLayout.addView(button_BIO_Record_Table);

android:layout_width and android:layout_height that I set on
button.xml did not have any effect(The button won't align to the right
of the screen).

However, when I added

button_BIO_Record_Table.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

It works fine(The button would align to the right of the screen).

Did I mess up with anything?

Thank you very much for your kindly assistance and sorry for my poor
English.

Best Regards,

Ray





-- 

2. RadioButton on the right side of my view

What I'm attempting to do is set a drawable on the left a text in the
middle then the radio button itself on the right. Any ideas?

Thanks in advance,

-gustavo

-- 

3. My installed app wont display on home screen in emulator

4. program crash on moto droid and g1

5. removed android library

6. APK dependencies

7. Bayes algorithm implementation in android for image data?