/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//In for instance onOptionsItemSelected event call showDialog(MY_ABOUT_DLG_CONSTANT); //Then override the onCreateDialog event, and check for //the int constant that you passed in showDialog. @Override switch (id) { case MY_ABOUT_DLG_CONSTANT: { /* Use the alert dialog builder to create the dialog, and add the string constants "R.string.aboutXXX" in "strings.xml". Then also add a dialog.xml layout. */ AlertDialog.Builder d = new AlertDialog.Builder(this); d.setTitle(R.string.aboutTitle); d.setIcon(android.R.drawable.ic_menu_info_details); d.setPositiveButton(R.string.aboutHomepage, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Uri uri = Uri.parse(getString(R.string.aboutHomepageUrl)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); //Just add additional buttons like the button above but add them //using d.setNeutralButton instead of positive button. d.setNegativeButton(R.string.aboutClose, null); TextView text = (TextView) v.findViewById(R.id.dialogText); text.setText(getString(R.string.aboutText, getVersion())); d.setView(v); return d.create(); } } } /****************** dialog.xml layout ******************** <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="6dip"> <TextView android:id="@+id/dialogText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="12sp" android:text="Example text." /> </ScrollView> *******************/