200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Android UI开发第四篇——实现像handcent sms或者chomp sms那样的气泡短信样式

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

时间:2020-10-09 06:35:35

相关推荐

Android 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="/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="/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; } }

/home.php?mod=space&uid=14682&do=blog&id=2518

本文转自xyz_lmn51CTO博客,原文链接:/xyzlmn/817381,如需转载请自行联系原作者

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。