`
shinfocom
  • 浏览: 1242369 次
文章分类
社区版块
存档分类
最新评论

UI开发第四篇——实现像handcent sms或者chomp sms那样的气泡短信样式

 
阅读更多

今晚有点时间把断了很长时间的UI开发补一下,这次实现的是像handcent sms或者chomp sms那样的气泡短信样式,也是iphone上的气泡聊天模式。实现这种效果的重点是ListView的divider和listSelector。先看一下效果图。

给代码:
(1)listview:
<?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:background="@android:color/white"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@null"
android:dividerHeight="0dip"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/list_item_style"
android:id="@+id/itemlist" />
</LinearLayout>

(2)ListView item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:background="@drawable/bg"></TextView>
</LinearLayout>

(3)java:

public class HandcentList extends Activity {
/** Called when the activity is first created. */
ListView itemlist = null;
List<Map<String, Object>> list;
final String[] str={"A","B","C","D","E","F"};
/** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
itemlist = (ListView) findViewById(R.id.itemlist);
refreshListItems();
}
private void refreshListItems() {
list = buildListForSimpleAdapter();
SimpleAdapter notes = new SimpleAdapter(this, list, R.layout.item,
new String[] { "str" }, new int[] { R.id.TextView01,});
itemlist.setAdapter(notes);
itemlist.setSelection(0);
}
private List<Map<String, Object>> buildListForSimpleAdapter() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(2);
// Build a map for the attributes
Map<String, Object> map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵");
list.add(map);

map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵\n呵呵呵呵\n呵呵\n呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵呵呵呵呵\n呵呵呵呵");
list.add(map);
return list;
}
}

http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2518

/**
* @author 张兴业
* 邮箱:xy-zhang@163.com
* qq:363302850
*
*/

分享到:
评论

相关推荐

    android气泡列表

    http://blog.csdn.net/xyz_lmn/article/details/6906331 这次实现的是像handcent sms或者chomp sms那样的气泡短信样式,也是iphone上的气泡聊天模式。实现这种效果的重点是ListView的divider和listSelector。

    android气泡式对话列表

    在Android开发中,创建一个类似Handcent SMS或Chomp SMS的气泡对话列表是一种常见的需求,这同样也是iPhone上常见的气泡聊天模式。这个模式以其直观、用户友好的设计,深受用户喜爱。本文将深入探讨如何实现这样的...

    Handcent+SMS+v3.9.9.9.apk

    仿iphone短信软件,希望大家喜欢。此资源为其他网站下载资源。

    SVOX Classic TTS-3.1.2_E带破解器 附安装说明

    SVOX Mandarin是一款中文普通话语音插件,可以支持多种语言阅读,第三方语音识别软件也可使用,例如:超级短信Handcent Sms,谷歌地图导航等,需要TTS及语音包。安装步骤: 1、由于我们是ICS4.0的系统,只有最新...

    Android手机实用软件全集下载

    2. HANDCENT SMS:这是一款强大的短信管理软件,提供对话式的短信界面,类似于iPhone的体验。除了美观的界面,它还支持大头贴显示,并且经常更新,不断优化用户体验。对于喜欢个性化短信应用的用户来说,这是必备...

    apktool反编译步骤

    在Android开发中,有时我们需要对现有的APK文件进行反编译以了解其内部结构或进行修改。本文将详细介绍使用APKTool进行APK文件反编译的具体步骤及注意事项。 #### 二、准备工作 在正式开始反编译之前,首先确保...

    SD卡中常见的文件夹名称及其作用.docx

    10. `handcent`:Handcent短信应用的数据。 11. `handyCurrency`:货币汇率应用的文件。 12. `ireader`:iReader阅读器的缓存。 13. `KingReader`:开卷有益的缓存和应用数据。 14. `LazyList`:Applanet应用商店的...

    Android系统中各类文件夹名称(SD卡)

    10. handcent:handcent(超级短信)的数据文件夹。 11. handyCurrency:货币汇率相关文件夹。 12. ireader:ireader的缓存文件夹。 13. KingReader:开卷有益的缓存文件夹。 14. LazyList:Applanet的缓存目录。 ...

    安卓手机文件夹名称大全.doc

    - **描述**:Handcent(超级短信)的数据文件夹。 - **作用**:存储短信相关信息。 - **注意事项**:定期清理有助于释放存储空间。 #### handyCurrency - **描述**:与货币汇率相关的文件夹。 - **作用**:存储货币...

Global site tag (gtag.js) - Google Analytics