• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

development


Commit MetaInfo

修訂8f5361ba0d9eeaded8bcf9d1b14dbcfce7cc13fb (tree)
時間2009-08-27 00:48:03
作者Muthu Ramadoss <muthu.ramadoss@gmai...>
CommiterJean-Baptiste Queru

Log Message

Enhancement: ApiDemos - App - Dialog - AlertDialog with MultipleChoices backed by Cursor

Added an example for using AlertDialog in Multichoice mode backed up by Cursor. This example can be used to test the following bug: http://code.google.com/p/android/issues/detail?id=955

AMEND:
Added a Toast to display readonly status of cursor, so data will not be updated.
Removed empty code blocks, which did nothing.

Change Summary

差異

--- a/samples/ApiDemos/res/layout/alert_dialog.xml
+++ b/samples/ApiDemos/res/layout/alert_dialog.xml
@@ -41,6 +41,9 @@
4141 <Button android:id="@+id/checkbox_button"
4242 android:layout_width="fill_parent" android:layout_height="wrap_content"
4343 android:text="@string/alert_dialog_multi_choice"/>
44+ <Button android:id="@+id/checkbox_button2"
45+ android:layout_width="fill_parent" android:layout_height="wrap_content"
46+ android:text="@string/alert_dialog_multi_choice_cursor"/>
4447 <Button android:id="@+id/text_entry_button"
4548 android:layout_width="fill_parent" android:layout_height="wrap_content"
4649 android:text="@string/alert_dialog_text_entry"/>
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -263,6 +263,7 @@
263263 <string name="alert_dialog_select_button">List dialog</string>
264264 <string name="alert_dialog_single_choice">Single choice list</string>
265265 <string name="alert_dialog_multi_choice">Repeat alarm</string>
266+ <string name="alert_dialog_multi_choice_cursor">Send Call to VoiceMail</string>
266267 <string name="alert_dialog_progress_button">Progress dialog</string>
267268 <string name="alert_dialog_text_entry">Text Entry dialog</string>
268269 <string name="alert_dialog_username">Name:</string>
--- a/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.java
@@ -28,6 +28,9 @@ import android.view.LayoutInflater;
2828 import android.view.View;
2929 import android.view.View.OnClickListener;
3030 import android.widget.Button;
31+import android.widget.Toast;
32+import android.database.Cursor;
33+import android.provider.Contacts;
3134
3235 import com.example.android.apis.R;
3336
@@ -60,6 +63,7 @@ public class AlertDialogSamples extends Activity {
6063 private static final int DIALOG_SINGLE_CHOICE = 5;
6164 private static final int DIALOG_MULTIPLE_CHOICE = 6;
6265 private static final int DIALOG_TEXT_ENTRY = 7;
66+ private static final int DIALOG_MULTIPLE_CHOICE_CURSOR = 8;
6367
6468 private static final int MAX_PROGRESS = 100;
6569
@@ -193,6 +197,28 @@ public class AlertDialogSamples extends Activity {
193197 }
194198 })
195199 .create();
200+ case DIALOG_MULTIPLE_CHOICE_CURSOR:
201+ String[] projection = new String[] {
202+ Contacts.People._ID,
203+ Contacts.People.NAME,
204+ Contacts.People.SEND_TO_VOICEMAIL
205+ };
206+ Cursor cursor = managedQuery(Contacts.People.CONTENT_URI, projection, null, null, null);
207+ return new AlertDialog.Builder(AlertDialogSamples.this)
208+ .setIcon(R.drawable.ic_popup_reminder)
209+ .setTitle(R.string.alert_dialog_multi_choice_cursor)
210+ .setMultiChoiceItems(cursor,
211+ Contacts.People.SEND_TO_VOICEMAIL,
212+ Contacts.People.NAME,
213+ new DialogInterface.OnMultiChoiceClickListener() {
214+ public void onClick(DialogInterface dialog, int whichButton,
215+ boolean isChecked) {
216+ Toast.makeText(AlertDialogSamples.this,
217+ "Readonly Demo Only - Data will not be updated",
218+ Toast.LENGTH_SHORT).show();
219+ }
220+ })
221+ .create();
196222 case DIALOG_TEXT_ENTRY:
197223 // This example shows how to add a custom layout to an AlertDialog
198224 LayoutInflater factory = LayoutInflater.from(this);
@@ -281,6 +307,14 @@ public class AlertDialogSamples extends Activity {
281307 }
282308 });
283309
310+ /* Display a list of checkboxes, backed by a cursor */
311+ Button checkBox2 = (Button) findViewById(R.id.checkbox_button2);
312+ checkBox2.setOnClickListener(new OnClickListener() {
313+ public void onClick(View v) {
314+ showDialog(DIALOG_MULTIPLE_CHOICE_CURSOR);
315+ }
316+ });
317+
284318 /* Display a text entry dialog */
285319 Button textEntry = (Button) findViewById(R.id.text_entry_button);
286320 textEntry.setOnClickListener(new OnClickListener() {