我在自己的應用中包含了自定義AlertDialog。將Galaxy Nexus更新爲Jelly Bean後,對話框不再顯示。只有屏幕變暗。對話周圍的過程(如加載數據)正在完美工作。在較舊的操作系統版本上,代碼工作(包括ICS 4.0.4)。自定義AlertDialog未出現在果凍豆上
無論對話框是創建並顯示在AsyncTask還是外部,都會出現問題。
有沒有人有類似的問題?
下面是代碼:
public class TLProgressDialog extends AlertDialog{
/*Log tag */
@SuppressWarnings("unused")
private static final String TAG = "TLProgressDialog";
@SuppressWarnings("unused")
private Context context;
private AnimationDrawable animation;
protected TLProgressDialog(Context context) {
super(context);
this.context = context;
}
public TLProgressDialog(Context context, boolean cancelable,
OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
this.context = context;
}
public TLProgressDialog(Context context, int theme) {
super(context, theme);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tlprogressdialog);
ImageView img = (ImageView)findViewById(R.id.dialog_img);
img.setBackgroundResource(R.drawable.tlprogress_animation);
animation = (AnimationDrawable) img.getBackground();
img.post(new Starter());
}
public static TLProgressDialog show(Context context){
TLProgressDialog dlg = new TLProgressDialog(context);
dlg.setCanceledOnTouchOutside(false);
dlg.setCancelable(false);
dlg.show();
return dlg;
}
private class Starter implements Runnable {
public void run() {
animation.start();
}
}
}
的XML佈局只是一個單一的ImageView其hostes動畫圖像:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/dialog_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
我的錯,只是發現我已經包含了動畫的GIF。這似乎不工作了。轉換爲PNG後,再次運行。 – AlexVogel 2012-07-25 06:41:35