Hello, all!
For some reason, I need a dialog with "backgroundDimAmount=0".
But I found that if I start a "new" emulator, show my dialog will get
a black screen, and never come back even press BACK key. This will
happen every time I test on 1.6 donut version.
To solve it is to show any dialog without this setting first in my
activity or not, and then my dialog will work well.
I could not figure out why this is happened. Is that a bug?
Anyone could test using the following sample code.
public class mydialog extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//showDialog(0); // backgroundDimAmount default setting
showDialog(1); // backgroundDimAmount=0
}
@Override
protected Dialog onCreateDialog(int id) {
if(id==0)
{
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);
return dialog;
}
else
{
Dialog dialog = new Dialog(this,R.style.Theme_doNotDim);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog with doNotDim");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);
return dialog;
}
}
}
# res/layout/custom_dialog.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>
# res/value/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.doNotDim" parent="@android:style/Theme.Dialog">
<item name="android:backgroundDimAmount">0</item>
</style>
</resources>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en