自定义AlertDialog 问自己的单选item
为什么80%的码农都做不了架构师?>>>
1.主要dialog.setAdapter
public static void showContextMenu(Context context, String title, BaseAdapter adapter, final DialogInterface.OnClickListener itemclickListener) {Builder dialog = new AlertDialog.Builder(context);dialog.setTitle(title);dialog.setAdapter(adapter, new OnClickListener(){@Overridepublic void onClick(DialogInterface dialog, int which) {itemclickListener.onClick(dialog, which);}});dialog.show();}
public class ChooseGroupAdapter extends KKBaseAdapter<Group>
{public ChooseGroupAdapter(Context context) {super(context);}@Overridepublic int onGetItemLayout() {return R.layout.layout_list_item;}@Overridepublic void onGetView(final View convertView, final int position) {Group p = mDataList.get(position);TextView item_title = findViewById(convertView, R.id.item_title);item_title.setText(p.getName());}}
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/item_title"android:layout_width="match_parent"android:layout_height="50dp"android:gravity="center" />
2.自定义ArrayAdapter 使用自己的布局和自己的数据
final ArrayAdapter<products> chooseProductAdapter = new ArrayAdapter<products>(this, R.layout.layout_list_item, baseBean.getChooseProduct()){@Overridepublic View getView(int position, View convertView, ViewGroup parent) {if (convertView == null) {convertView = ViewUtil.inflateView(R.layout.layout_list_item, parent);}final TextView text1 = (TextView) convertView.findViewById(R.id.item_title);final String display = this.getItem(position).getName();text1.setText(display);return convertView;}};
转载于:https://my.oschina.net/sfshine/blog/486474
自定义AlertDialog 问自己的单选item相关推荐
- 自定义AlertDialog.Builder对话框
在工作中,原生态的AlertDialog已经远远不能满足我们工作的需求,这时候,就需要使用自定义的AlertDialog.Builder: 在自定义之前,我们先了解下, **原生态的AlertDial ...
- 创建自定义AlertDialog
没什么特别的地方,只是自定义弹出一个简单的对话框. 效果图: 首先定义一个布局文件 custom_dialog.xml: <?xml version="1.0" encodi ...
- 自定义AlertDialog控件的使用(AndroidStudio)
自定义AlertDialog控件的使用(AndroidStudio) AlertDialog 第一种:可随意自定义控件 第一步:自定义弹出的页面 ,新建一个XML页面 如下图 不需要Activity ...
- android activity传值到dialog,android 自定义AlertDialog 与Activity相互传递数据
**主要实现功能:** 1.从Activity的TextView中获取字符串设置到AlertDialog的TextView和EditText中 2.将AlertDialog的EditText中的值设置 ...
- Android 自定义AlertDialog类
还是先从最简单的开始吧,然后一步一步的扩展. 为了保证软件上所谓的低耦合度和可重用性,这里不得不需要单独建立一个类CustomerDialog,然后继承AlertDialog public class ...
- Android自定义AlertDialog的控件获取操作
Android自定义AlertDialog的控件获取操作 在自定义的AlertDialog布局虽然可以显示,但是试过很多方法都不能获得其中的控件进行操作,找了很多方法最后这种方法可以. dialog的 ...
- 自定义AlertDialog布局
2019独角兽企业重金招聘Python工程师标准>>> 先看效果图: 附上代码: // 1. 布局文件转换为View对象 LayoutInflater inflater = Layo ...
- Android 自定义AlertDialog对话框
2019独角兽企业重金招聘Python工程师标准>>> 系统默认的AlertDialog,与项目的UI不统一,所以,改了一下,定义了一样式,最终效果如下图: 另外,为了尽量少改原来的 ...
- Android之自定义AlertDialog无法监听控件
参考:http://www.cnblogs.com/511mr/archive/2011/10/21/2220253.html 要做一个自定义的弹出框,以前都是用一个Activity来实现,总觉得不是 ...
最新文章
- C# WinForm 技巧四:COMBOBOX搜索提示
- 包子和饺子之扫地机器人_智能家居篇之扫地机器人
- 适合vue的富文本框
- C语言交换两个数的值与形参与实参理解
- python--通过xpath相对节点位置查找元素(续)
- windows环境下wampserver的配置教程
- 《分布式系统:概念与设计》一1.3 分布式系统的趋势
- 与大家分享一下2010我的找工作历程!真累啊!不过都已经结束了!
- linux ssh非交互脚本,Linux expect非交互式执行脚本
- 【我的物联网成长记10】五分钟了解物联网SIM卡【华为云技术分享】
- java实现deflate算法
- 简要说明php数组的类型,php数组的概述及分类与声明代码演示
- Android视频播放器demo
- 解析数论引论 第1章 算术基本定理
- 英文标题中的字母大写规则
- 已知 XYZ+YZZ=532,其中,X、Y、Z 为数字,编程求出 X、Y 和 Z 的值
- 国内外10大项目外包平台
- C语言求任意数的阶层
- 随笔-springBoot配置全局跨域
- 关于谷歌账户的目标设置疑问解答
热门文章
- 由于采用分时技术 用户可以独占计算机资源,计算机操作系统第1章练习题
- c# imager让图片有圆角unity_Qt编写自定义控件24-图片轮播控件
- 全球及中国4-氨基-3-硝基苯酚行业前景趋势与投资规模格局报告2022版
- 2022年的东南亚跨境市场风口,越南电商市场一定不要错过
- 全球及中国自动驾驶行业应用领域及投资前景展望报告2022-2028年版
- Openssl和PKCS#11的故事
- addShutdownHook钩子
- Codeforces Round #499 (Div. 2) Problem-A-Stages(水题纠错)
- 缩点+染色+DFS codeforce467D
- bzoj 1968: [Ahoi2005]COMMON 约数研究【枚举】