1:和ListView的数据跟新是基本一样的。

2:Activity代码示例

public class MainActivity extends AppCompatActivity {

    AlertDialog alertDialog;
View view;
List<String> data = new ArrayList<>();
ListView listView;
ArrayAdapter<String> adapter; Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
adapter.notifyDataSetChanged();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
for (int i = 0; i < 100; i++) {
data.add("数据:" + i);
} view = getLayoutInflater().inflate(R.layout.controller_volume, null);
alertDialog = new AlertDialog.Builder(this).setTitle("Dialog ListView更新")
.setIcon(R.mipmap.ic_launcher)
.setView(view)
.setPositiveButton("return", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface paramAnonymousDialogInterface,
int paramAnonymousInt) { }
}).create();
listView=view.findViewById(R.id.listView);
adapter=new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1,data);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
data.remove(data.get(position));
handler.sendEmptyMessageDelayed(100,1000);
}
}); alertDialog.show();
} }

  

3:controller_volume.xml 只有一个listView

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/listView"/>
</android.support.constraint.ConstraintLayout>

  

Android AlertDialog 动态更新里面的ListView数据的更多相关文章

  1. Android中动态更新ListView(转)

    在使用ListView时,会遇到当ListView列表滑动到最底端时,添加新的列表项的问题,本文通过代码演示如何动态的添加新的列表项到ListView中.实现步骤:调用ListView的setOnSc ...

  2. (转)android res文件夹里面的drawable(ldpi、mdpi、hdpi、xhdpi、xxhdpi)

    android res文件夹里面的drawable(ldpi.mdpi.hdpi.xhdpi.xxhdpi) (1)drawable-hdpi里面存放高分辨率的图片,如WVGA (480x800),F ...

  3. cocos2dx中android下动态更新.so文件

    作者:HU 转载请注明,原文链接:http://www.cnblogs.com/xioapingguo/p/4037595.html  因为没用lua脚本写游戏,所以每次发布出去后,发现在bug,需要 ...

  4. android清除本应用里的各种数据的方法

    public class DataCleanManager { /** * * 清除本应用内部缓存(/data/data/com.xxx.xxx/cache) * * * * @param conte ...

  5. 反序列化存入数据库里面的session数据

    session数据存取的方法可通过session.serialize_handler方法来判断,反序列化可通过下面的unserialize方法,参考http://stackoverflow.com/q ...

  6. Fragment里面的ListView的item点击没反应

    近期做一个消息列表,发现fragment的listview载入消息出来后,每条消息都点击不了.经过询问和查下已解决 开发中非经常见的一个问题,项目中的listview不不过简单的文字,经常须要自定义l ...

  7. Android中动态更新TextView上的文字

    示例代码: 1.新线程,定时更新文字 class testThread extends Thread{ public void run() { Message message = new Messag ...

  8. python中pandas里面的dataframe数据的筛选小结

    pandas大家用的都很多,像我这种用的不够熟练,也不够多的就只能做做笔记,尽量留下点东西吧. 筛选行: a. 按照列的条件筛选 df = pandas.DataFrame(...) # suppos ...

  9. Android原生调用mui里面的js如何实现

    遍历所有运行中的webview页面,采用自带的SDK方法进行获取所有的IWebview.MUI中自带的webview是一个IWebviewArrayList<IWebview> webli ...

随机推荐

  1. Laravel -- windows apache .htaccess https 路由重写

    一: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{SERVER_PORT} !^443 RewriteCond %{RE ...

  2. day37-3 异常处理

    目录 异常处理 捕捉异常 raise assert 异常处理 捕捉异常 语法错误无法通过try检测,就像函数一样 try: 1/0 except Exception as e: # Exception ...

  3. Html-如何正确给table加边框

    一般来说,给表格加边框都会出现不同的问题,以下是给表格加边框后展现比较好的方式 <style> table,table tr th, table tr td { border:1px so ...

  4. S-HR快速查看shr日志

    http://localhost:6888/shr/appData.do?method=getApplicationLog&logFile=apusic.log.0&instance= ...

  5. C#第十四节课

    函数的调用 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System ...

  6. Cursor、Exception、Procedure、Function、Package、Trigger(day06)

    回顾: 1.record类型 定义record类型,声明变量,保存s_dept表中id = 31部门信息 declare /* 定义record类型 */ type deptrecord is rec ...

  7. CodeVS 1013&1029

    若干二叉树遍历的数据结构题. Problem 1013 传送门:http://codevs.cn/problem/1013/ 本题是一个数据结构——二叉树遍历问题. 对二叉树,给定中序遍历序列(In- ...

  8. States of Integrity Constraints

    States of Integrity Constraints As part of constraint definition, you can specify how and when Oracl ...

  9. 转载 - KMP算法

    出处:http://www.cnblogs.com/dolphin0520/archive/2011/08/24/2151846.html KMP算法 在介绍KMP算法之前,先介绍一下BF算法. 一. ...

  10. 0804关于mysql 索引自动优化机制: 索引选择性(Cardinality:索引基数)

    转自http://blog.csdn.net/zheng0518/article/details/50561761 1.两个同样结构的语句一个没有用到索引的问题: 查1到20号的就不用索引,查1到5号 ...