使Android应用的AlertDialog对话框中的按钮显示为ImageButton图标,并设置相应
来源:互联网 发布:镜面蛋糕走红网络 编辑:程序博客网 时间:2024/06/02 05:07
最终示意图如下所示:
首先需要新建一个layout文件:new_layout.xml: 这里定义有三个按钮
<?xml version="1.0" encoding="UTF-8" ?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="15dp" android:gravity="center_horizontal" android:background = "#FFFFFF" android:orientation="horizontal"> <!-- game button --> <ImageButton android:id="@+id/game" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="5dp" android:layout_gravity="bottom" android:background = "#00ffffff" android:src="@drawable/game"/> <!-- browser button --> <ImageButton android:id="@+id/browser" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="5dp" android:layout_gravity="bottom" android:background = "#00ffffff" android:src="@drawable/browser"/> <!-- email button --> <ImageButton android:id="@+id/email" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="5dp" android:layout_gravity="bottom" android:background = "#00ffffff" android:src="@drawable/email"/> </LinearLayout>
final AlertDialog alertDialog = new AlertDialog.Builder(TalkerActivity.this).create(); alertDialog.show(); Window win = alertDialog.getWindow(); //设置自定义的对话框布局 win.setContentView(R.layout.new_layout); //游戏按钮事件 ImageButton game_btn = (ImageButton)win.findViewById(R.id.game); game_btn.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub } }); //浏览器程序 ImageButton browser_btn = (ImageButton)win.findViewById(R.id.browser); browser_btn.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub } }); //电子邮件程序 ImageButton email_btn = (ImageButton)win.findViewById(R.id.email); email_btn.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub } });
- 使Android应用的AlertDialog对话框中的按钮显示为ImageButton图标,并设置相应
- Android Studio AlertDialog 为对话框添加按钮
- android 控件 带图标的按钮(ImageButton)
- Android 覆盖AlertDialog里的按钮事件并显示Toast
- Android UI之ImageButton(带图标的按钮)
- 玩转Android---UI篇---ImageButton(带图标的按钮)
- Android设置AlertDialog点击按钮对话框不关闭(转)
- 如何为JOPtionPane的showConfirmDialog对话框中的按钮设置监听
- Android中的对话框AlertDialog
- android 提示对话框显示 AlertDialog
- Android中显示AlertDialog对话框
- 对话框实现选择文件,并显示相应的路径
- Android对话框的高级设置《二》设置对话框按钮的透明度和对话框的在屏幕上的显示位置
- Android中的对话框(一)AlertDialog
- 检索Android SDCard的图片,并显示到imagebutton
- 检索Android SDCard的图片,并显示到imagebutton
- Android:在AlertDialog点击按钮隐藏对话框
- Android开发之AlertDialog对话框内gallery的应用案例
- 查找只出现一次的字符串
- Android开发(24)---安卓中实现多线程下载(带进度条和百分比)
- JAVA------sort-----------------排序
- building android/ubuntu-touch on 32bit machine
- flyweight
- 使Android应用的AlertDialog对话框中的按钮显示为ImageButton图标,并设置相应
- Listview中布局控件导致点击事件失效的原因分析
- WSO2 ESB(4)
- Trie树和Ternary Search树的学习总结
- 设计模式_迭代模式
- 有用的前端工具和资料
- python中的OptionParser
- IT术语之“I”
- getCurrentSession 与 openSession() 的区别