自定义dialog
来源:互联网 发布:手机淘宝如何重新登录 编辑:程序博客网 时间:2024/06/11 18:52
概要
- 继承 android的Dialog类
- 在onCreate方法中设置自定义的dialog的内容
- .如果想要修改dialog的一些特性(比如:宽高、内容颜色等,要在show()调用后再修改)
例子
- 继承 android的Dialog类
public class ScoreDialog extends Dialog implements View.OnClickListener {
- 在onCreate方法中设置自定义的dialog的内容
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); View contentView = View.inflate(getContext(), R.layout.pc_view_edittextdialog, null); setContentView(contentView); mDialogView = getWindow().getDecorView().findViewById(android.R.id.content); score_et = (EditText) findViewById(R.id.score_et); //score_et.setFilters(new InputFilter[]{new InputFilter10()}); commit_tv = (TextView) contentView.findViewById(R.id.commit_tv); commit_tv.setOnClickListener(this); }
- 如果想要修改dialog的一些特性(比如:宽高、内容颜色等,要在show()调用后再修改)
public void show() { super.show(); // 修改Dialog的宽高 Window window = getWindow(); WindowManager windowManager = window.getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = window.getAttributes(); lp.height = WindowManager.LayoutParams.WRAP_CONTENT; ApplicationProxy singleInstance = ApplicationProxy.getSingleInstance(); Context applicationContext = singleInstance.getApplicationContext(); lp.width = (int) applicationContext.getResources().getDimension(R.dimen.pc_dimen_315dp); window.setAttributes(lp); }
public void btn(View view) { ScoreDialog editTextDialog = new ScoreDialog(this); editTextDialog.show(); editTextDialog.setHitText("hahahaha"); }
0 0
- 自定义Dialog---继承Dialog
- 自定义Dialog android Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义dialog
- 自定义 Dialog
- 自定义dialog
- 自定义 dialog
- 自定义Dialog
- 自定义 Dialog
- 自定义Dialog
- 自定义dialog
- 自定义Dialog
- 自定义 Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义Dialog
- 适配器模式
- 人见人爱A^B
- 5、HotSpot的算法实现
- 标签中onclick绑定函数却is not defined的原因
- 斗地主-比较牌大小算法
- 自定义dialog
- 动态内存管理:模拟实现memcpy,memmove
- 杨辉三角
- CodeForces 5891 Lottery
- 在freecodecamp练习的算法题心得记录
- HDOJ 1914 The Stable Marriage Problem
- Android自定义View【实战教程】5⃣️---Canvas详解及代码绘制安卓机器人
- yande.re Y站API翻译
- 备忘录模式