我在一个分片活动中有一个Viewpager,它有一个带有编辑文本和发送按钮的botton框架。 在片段布局中,我有一个ListView,并在片段中附加了一个适配器。现在我正在实现从片段中的Parent的发送按钮,点击试图通过适配器将编辑文本中的文本(再次从父文件)添加到列表(在片段中)。但这里的问题是,当我输入一些文本,然后单击发送其添加文本不在当前浏览器中的视图,但到下一个,当我去最后一个项目时,它添加到相同的视图(这是预期的)。有时候它的随机不是按照下一个项目的顺序。 片段活动布局:Android查看带有列表视图的分页器并动态添加文本

android:id="@+id/detailLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:clickable="true"

android:orientation="vertical" >

android:id="@+id/pager"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_above="@+id/form" >

android:id="@+id/form"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:orientation="horizontal"

android:padding="2dp" >

android:id="@+id/editText"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_centerVertical="true"

android:layout_toLeftOf="@+id/btnSend"

android:drawableRight="@drawable/edit_keyboard"

android:inputType="textMultiLine"

android:maxLines="3" />

android:id="@+id/btnSend"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:layout_centerVertical="true"

android:src="@drawable/send" />

片段布局:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

android:id="@+id/imageView"

android:layout_width="match_parent"

android:layout_height="match_parent" />

android:id="@+id/listView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@android:color/transparent"

android:cacheColorHint="@android:color/transparent"

android:divider="@android:color/transparent"

android:listSelector="@android:color/transparent"

android:scrollbars="none" />

下面是我实现发送的ImageButton:

ImageButton sendBtn = (ImageButton) getActivity().findViewById(R.id.btnSend);

sendBtn.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

String msg = msgBox.getText().toString();

if (msg.length() > 0) {

long date = new Date().getTime();

// TODO Auto-generated method stub

commentAdapter.add(new OneComment(false, msg, "Me",

String.valueOf(date), "0"));

msgBox.setText("");

} else

Toast.makeText(getActivity(), "type in some text..", Toast.LENGTH_SHORT).show();

}

});

2013-02-05

sukarno

android 文本分页显示,Android查看带有列表视图的分页器并动态添加文本相关推荐

  1. android listview分页显示,Android应用中使用ListView来分页显示刷新的内容

    点击按钮刷新1.效果如下: 实例如下:  上图的添加数据按钮可以换成一个进度条  因为没有数据所以我加了一个按钮添加到数据库用于测试:一般在服务器拉去数据需要一定的时间,所以可以弄个进度条来提示用户: ...

  2. android自定义listview 显示数组,android中使用arrayadapter类的自定义列表视图

    从https://groups.google.com/forum/?fromgroups#!topic/android-developers/No0LrgJ6q2M绘制 public class Ma ...

  3. Android数据库 分页查询,Android之怎么使用SQLite数据库(增、删、改、查、分页等)以及ListView显示数据(转)...

    由于刚接触android开发,故此想把学到的基础知识记录一下,以备查询,故此写的比较啰嗦: 步骤如下: 一.介绍: 此文主要是介绍怎么使用android自带的数据库SQLite,以及把后台的数据用Li ...

  4. Android日期分组,按查询分组在列表视图android中显示一些意...

    我有一个列表视图,其中显示了从联系人号码收到的消息.现在的问题是,如果我收到来自" 1234567"的5条消息和来自" 56789"的3条消息,那么我的主列表视 ...

  5. android notification 定时显示,Android编程使用Service实现Notification定时发送功能示例...

    本文实例讲述了android编程使用service实现notification定时发送功能.分享给大家供大家参考,具体如下: /** * 通过启动或停止服务来管理通知功能 * * @descripti ...

  6. android编辑框显示,android – 如何在屏幕上显示文本编辑框?

    您的问题最简单的解决方案是在您主要(肖像修复的)活动中启动的单独的对话框主题的活动中显示您的EditText. EditText Activity不应该将其方向固定,因此它会沿着您滑出键盘时的期望旋转 ...

  7. android 360状态栏显示,Android高仿UC浏览器和360手机卫士消息常驻栏(通知栏)

    之前网上看了下自定义消息栏,通知栏,了解到了Notification这个控件,发现UC浏览器等都是这种类型,今天写个demo实现下,如图: 其中每个按钮都有不同的功能,代码如下: package co ...

  8. android 更新适配器,android – 当适配器数据更改时更新列表视图

    当与阵列适配器关联的数据更改时,使列表视图无效足以显示更新的值?下面的代码不工作,我误解了这里的东西. public class ZeroItemListActivity extends Activi ...

  9. android图片解码显示,android 图片解码显示流程

    问题来源 android 可以在 gallery 里面显示内部存储的图片,支持 jpeg,png,gif,bmp 等,甚至文件类型和图片后缀名不一致,只要是图片文件就能显示,然后 git 只会显示第一 ...

最新文章

  1. TCP连接管理【三次握手-四次挥手】
  2. Visual Studio 15改进C++工程加载
  3. 1.12 深层循环神经网络-深度学习第五课《序列模型》-Stanford吴恩达教授
  4. 分布式的事务该怎么做?
  5. (64)句柄表,遍历所有进程的句柄表实现反调试
  6. python 如果没有该key值置为空_在python字典中用“None”替换空值
  7. 语言zzuli链表遍历_趣味图解算法之链表
  8. atmega8a如何烧写程序_如何让树莓派4上固件的debug日志输出到串口?
  9. 微型计算机用什么评价判断,环评中常用评价等级的判定
  10. mediarecorder添加时间戳_Python脚本实现数据处理(官方实例)和Hive自带时间函数...
  11. android自动化测试之robotium初探(三),Android自动化测试之Robotium--基础操作.pdf
  12. SpringBoot创建简单的hello world
  13. linux c 错误码大全及错误的捕获
  14. 【英语学习】【English L06】U08 News L5 They are expecting a baby!
  15. ansible+ssh自动化运维
  16. java的IO操作之--RandomAccessFile
  17. 最新版银灿如意烧AIBurn V2.0.0.1(支持IS903B/IS902E/IS916主控)
  18. html怎么让视频自动循环播放,【前端】div 加载视频并自动循环播放
  19. STL 常用容器的底层数据结构
  20. 论汽车车机快速启动与开机动画、倒车影像三者关系

热门文章

  1. Android学习笔记(十八)——使用意图筛选器和实现浏览网页(附源代码)
  2. 控股天弘基金 阿里无银行之名行银行之实
  3. SQLServer扩展存储过程
  4. 误删除MySQL数据库表的ibd文件怎么办
  5. java中 有return 的情况,return以及try,finally代码块的执行顺序
  6. Ecliplse安装tomcat插件
  7. 【Python】Python中的日志级别
  8. 【Oracle】Rman简介
  9. 【SQL】SELECT 语句
  10. 解决文件下载在火狐浏览器出现中文文件名乱码的方法