1
私は、ダイアログ内のコンテンツが動的なカスタムダイアログを作成しようとしています。私はダイアログにビューを渡し、そのビューをダイアログに追加します。現在のところ、カスタムビューと、ビューの幅と高さが0であるというメッセージは表示されません。Android - カスタムダイアログ
他のカスタマイズも含めて、カスタムビューをApplicationクラスで渡します。ここで
は私のダイアログクラスである:私のカスタムビューの
public class LoadingActivity extends Dialog
{
private LoadingActivity(Context a) {
super(a, android.R.style.Theme);
}
public static LoadingActivity show(Context context) {
LoadingActivity checkerLoader = new LoadingActivity(context);
View currentView = View.inflate(context, R.layout.loading_activity, null);
FrameLayout linearLayout = (FrameLayout) currentView.findViewById(R.id.circular_progress_bar);
RelativeLayout viewLayout = (RelativeLayout) currentView.findViewById(R.id.view_layout);
if (DataManager.getInstance().getAppConfigurations().getLoadingActivity() != null) {
View loadingView = DataManager.getInstance().getAppConfigurations().getLoadingActivity();
loadingView.setBackgroundColor(Color.RED);
loadingView.invalidate();
if(loadingView.getParent()!=null) {
((ViewGroup) loadingView.getParent()).removeView(loadingView);
}
viewLayout.addView(loadingView);
}
checkerLoader.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
checkerLoader.setContentView(currentView);
checkerLoader.setCancelable(false);
checkerLoader.getWindow().getAttributes().gravity = Gravity.CENTER;
WindowManager.LayoutParams lp = checkerLoader.getWindow().getAttributes();
lp.dimAmount=0.2f;
checkerLoader.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
checkerLoader.getWindow().setAttributes(lp);
checkerLoader.show();
return checkerLoader;
}
}
は、相続人の例:
public class Spinner extends LinearLayout
{
public Spinner(Context context) {
super(context);
init(context);
}
public Spinner(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public Spinner(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
View aView = View.inflate(context, R.layout.loading_activity, null);
ImageView logoImage = (ImageView) aView.findViewById(R.id.loading_image);
logoImage.setImageResource(R.drawable.loading_chicken2);
}
}