java - copy existing linearLayout to a runtime alertDialog
问题描述
I have a maintenance application, where the operator does a checklist, and the previous steps are disabled, but I need to be able to go back to the previous step, and I would like to do this in an alertDialog
I created a setOnLongClickListener and I'm getting the View, and trying to add in alertDialog, but I get the exception that the layout has a parent (), when I remove View with, removeView (), it works, but I can't remove the View of princiapal activity
passo1.setOnLongClickListener(v -> {
dialogBuilder = new AlertDialog.Builder(initManutencao.this);
if (v.getParent() != null){
((ViewGroup) v.getParent()).removeView(v);
}
dialogBuilder.setView(v);
alertDialog = dialogBuilder.create();
alertDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialog.show();
//disableItens.ShowItensScren(0, initManutencao.this);
return false;
});
In short, I need to copy a LinearLayout with all its contents to an alertDialog, without me removing it from the main activity when I press it.
Main Activity, should not be changed wanted but without removing LinearLayout from the main activity
解决方案
推荐阅读
- mysql - spring boot jpa:ddl-auto=create 不创建模式
- perl - Perl 失败的语言环境。你是怎么设置的?
- keycloak - 在 Keycloak 扩展中实现 AbstractOAuth2IdentityProvider 时出现 NoClassDefFoundError
- python - 为什么我不能让我的“def”函数正确输出文本?
- android - 如何使用 Spinner 从显示文本中获取不同的返回值?
- java - 无法序列化包含 orientdb 记录 ID 的地图
- javascript - 使用键值中的“:”访问 JSON 值
- java - 如何 JavaDoc 动作监听器
- jms - 挂起状态下的 Tibco JMS 队列发件人活动
- spring - Spring集成迁移问题