类似iphone的短消息效果
网上借的
[img]http://dl.iteye.com/upload/attachment/486826/08614876-945a-3c95-b6cb-3cf4c53bdc14.png[/img]
package com.ql.app;
import java.util.ArrayList;import java.util.List;
import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.ImageView;import android.widget.ListView;
public class ChatActivity extends Activity {
private ChattingAdapter adapter; private List<ChatMessage> messages = new ArrayList<ChatMessage>(); private ListView listView; private Button btn_send; private EditText textEditor; private ImageView btn_insert;
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
messages.add(new ChatMessage(ChatMessage.MESSAGE_FROM, "hello,android.")); messages.add(new ChatMessage(ChatMessage.MESSAGE_TO, "hello,java.")); messages.add(new ChatMessage(ChatMessage.MESSAGE_FROM, "请教高手,怎么可以给gridview设置边框啊,现在这个显示效果实在太难看了。")); messages.add(new ChatMessage(ChatMessage.MESSAGE_TO, "那就加点背景,加点属性什么的不就行了吗")); messages.add(new ChatMessage(ChatMessage.MESSAGE_FROM, "在主题中,将gridview的cssclass设置为gridview")); messages.add(new ChatMessage(ChatMessage.MESSAGE_TO, "谢谢")); listView=(ListView)findViewById(R.id.listView); adapter = new ChattingAdapter(this, messages); listView.setAdapter(adapter);
btn_send = (Button) findViewById(R.id.btn_send); textEditor = (EditText) findViewById(R.id.text_editor);
btn_insert=(ImageView) findViewById(R.id.btn_insert); btn_send.setOnClickListener(listener); btn_insert.setOnClickListener(listener); }
private View.OnClickListener listener = new View.OnClickListener() {
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_send: String str = textEditor.getText().toString(); String sendStr=str.trim(); if(!sendStr.equals("")){ sendMessage(sendStr); } textEditor.setText(""); break; case R.id.btn_insert: Intent i = new Intent(); i.setType("image/*"); i.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(i, Activity.DEFAULT_KEYS_SHORTCUT);
// Intent it = new Intent("android.media.action.IMAGE_CAPTURE");// startActivityForResult(it, Activity.DEFAULT_KEYS_DIALER); break; default: break; } }
// 模拟发送消息 private void sendMessage(String sendStr) { messages.add(new ChatMessage(ChatMessage.MESSAGE_TO, sendStr)); adapter.notifyDataSetChanged(); }
};
}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:focusable="false" android:focusableInTouchMode="false" android:background="@drawable/nav_page" android:gravity="center_horizontal" > <ListView android:id="@+id/listView" android:background="@null" android:scrollbars="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:listSelector="@null" android:transcriptMode="alwaysScroll" android:cacheColorHint="#00000000" android:divider="@null" android:layout_weight="1.0" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/txt_msg_bg" android:paddingRight="7.0dip" > <ImageView android:id="@+id/btn_insert" android:layout_gravity="center_vertical" android:paddingLeft="15.0dip" android:paddingTop="5.0dip" android:paddingRight="7.0dip" android:paddingBottom="5.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/sms_insert" /> <EditText android:id="@+id/text_editor" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:background="@drawable/sms_embeded_text_editor_bg" android:focusable="true" android:nextFocusRight="@+id/send_button" android:layout_marginLeft="7.0dip" android:layout_marginTop="5.0dip" android:layout_marginRight="7.0dip" android:layout_marginBottom="5.0dip" android:minHeight="34.0dip" android:hint="输入消息" android:maxLines="8" android:maxLength="2000" android:capitalize="sentences" android:autoText="true" android:layout_weight="1.0" android:inputType="textCapSentences|textAutoCorrect|textMultiLine|textShortMessage" android:imeOptions="actionSend|flagNoEnterAction" /> <Button android:id="@+id/btn_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_gravity="center_vertical" android:background="@drawable/sms_send_button_bg" android:paddingLeft="11.0dip" android:paddingRight="11.0dip" android:nextFocusLeft="@id/text_editor" /> </LinearLayout></LinearLayout>
整个工程:
类似iphone的短消息效果相关推荐
- WPF触控程序开发(三)——类似IPhone相册的反弹效果
原文: WPF触控程序开发(三)--类似IPhone相册的反弹效果 用过IPhone的都知道,IPhone相册里,当图片放大到一定程度后,手指一放,会自动缩回,移动图片超出边框后手指一放,图片也会自动 ...
- Android 类似未读短信图标显示数字效果的分析
之前一直以为是应用本身在对图标进行修改,看了源码之后发现其实主要的工作并不是应用自己完成的,主要的工作在是launcher里面完成的. 关于系统里面类似未读短信的具体处理流程如下, 原理 一个应 ...
- Android 类似未读短信消息图标显示的实现分析
这里面主要的工作在是launcher里面完成的. 关于系统里面类似未读短信的具体处理流程如下, 原理 一个应用要实现这个效果,就要在自己有未读的消息的时候发送一个广播告诉系统我有未处理的事件了(例如: ...
- 微信语音短消息amr文件转WAV
" 微信语音短消息amr文件转WAV." 在<SILK编码语音转WAV格式>中提到过,"腾讯系产品,包括QQ.微信.小程序,在语音相关的实现中,也大量使用到S ...
- Android-经典蓝牙(BT)-建立长连接传输短消息和文件
参考: https://developer.android.com/guide/topics/connectivity/bluetooth http://bbs.eeworld.com.cn/thre ...
- Cempi实战攻略(六)——如何截获到达的短消息
Cempi实战攻略(六)--如何截获到达的短消息 By 吴春雷 QQ:819543772 EMAIL:wuchunlei@163.com 1. MapiRule是什么?我从哪里能够得到它? ...
- vue自定义插件 封装一个类似 element 中 message 消息提示框的插件
vue自定义插件 封装一个类似 element 中 message 消息提示框的插件 一.资源文档 1.vue内置组件 transition 2.Vue.use() 3.Vue.extend() 4. ...
- ios+android备份短信恢复软件下载,iPhone备份短信教程:iOS短信导出技巧大全
iPhone备份短信怎么做?正所谓未雨绸缪,手机作为我们生活中最常用的手机数据,自然储存了很多个人隐私数据.未雨绸缪目的就在于避免损失或者将损失降低到最小,但是大多数情况下我们都是亡羊补牢.为了避免数 ...
- 织梦+php获取数据,DedeCms 用JS+PHP获取是否有新短消息
dedecms在会员中心的顶部有一系列横向的导航链接,其中就包括一个短信息的链接,如果有了未读短消息,就会用红色字体显示数量. 看起来效果不错,但是这页面是动态生成的,一旦想要把效果应用在静态页面上( ...
最新文章
- JIT Compiler编译器
- java与fabric区块链--fabric-ca-server 登记---(2)
- Python实训day14pm【Python网络爬虫综合大作业-参考解析】
- 从html导出带样式的excel,Jquery导出带样式的Excel
- vuerouter传参方式_VUE Router学习原理(一)
- 戴尔-EMC将至强Phi服务器与Tesla GPU纳入PowerEdge
- php里 \r\n换行问题
- java学习笔记(5)
- nginx导致的session丢失的解决方法
- System Information Viewer系统信息、硬件规格检测器
- oracle存储过程(带参数的存储过程)
- html js把json转化为excel,json转换Excel
- 归并排序算法(二路)——C/C++
- win7 无线网卡无法连接,启动wlan autoconfig 服务报错误1:函数不正确
- spring-security-oauth2(五) 记住我
- AngularJS知识概括
- 算法作业04(回溯与分支界限算法)(骑士游历与行列变换问题)
- linux 怎么刷新,Linux下要不要添加“刷新”按钮?Linux用户怎么看?以下附上评论...
- 实验室5位直博生每人一篇 Science!她再获颁“世界杰出女科学家奖”
- 哎呦,最近流行校内体哦--每个用 power shell 的程序员,上辈子都是折翼的天使
热门文章
- 微信小程序---代码构成讲解基础篇
- vue项目关闭页面后重新登录
- 信息通信行业支撑防范打击治理电信网络诈骗体系研究
- 获取《王者荣耀》全英雄高清无码图
- java中setSize(),setLocation(),setBounds三者之间的关系和用法
- android 6.0关闭开机启动器,Android实现开机自启动及开机自启动失败原因
- DDD 实战 (7):战术设计、整体流程与首次冲刺
- MAVEN 淘宝中央仓库
- 酒店数据分析预处理pandas
- 【华为账号服务】【FAQ】Account Kit常见咨询合集--获取帐号个人信息相关问题