超碰人人人人人,亚洲AV午夜福利精品一区二区,亚洲欧美综合区丁香五月1区,日韩欧美亚洲系列

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

Android 開發(fā)即時聊天工具 YQ :(七) 氣泡聊天

admin
2013年2月25日 14:27 本文熱度 4529

首先看看效果:






實現(xiàn)方式還是listview自定義adapter,只不過用了兩個布局文件,左邊的一種布局,右邊的一種布局,在消息實體類中添加一個變量,用來判斷是發(fā)出的消息還是收到的消息,從而在adapter的getView()中,決定采用哪種布局。




chat_listview_item_left.xml





[html]


  1. <?xml version="1.0" encoding="utf-8"?>  

  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  

  3.     android:layout_width="wrap_content"  

  4.     android:layout_height="wrap_content" >  

  5.     <ImageView  

  6.         android:id="@+id/avatar_chat_left"  

  7.         android:layout_width="wrap_content"  

  8.         android:layout_height="wrap_content"  

  9.         android:src="@drawable/avatar_default" />  

  10.     <RelativeLayout   

  11.         android:id="@+id/rl_chat_left"  

  12.         android:layout_width="wrap_content"  

  13.         android:layout_height="wrap_content"  

  14.         android:layout_toRightOf="@id/avatar_chat_left"  

  15.         android:background="@drawable/chat_left">  

  16.     <TextView  

  17.         android:id="@+id/message_chat_left"  

  18.         android:layout_width="wrap_content"  

  19.         android:layout_height="wrap_content"  

  20.         android:maxWidth="160dip"/>  

  21.     </RelativeLayout>  

  22.     <TextView  

  23.         android:id="@+id/sendtime_chat_left"  

  24.         android:layout_width="wrap_content"  

  25.         android:layout_height="wrap_content"  

  26.         android:layout_toRightOf="@id/avatar_chat_left"  

  27.         android:layout_below="@id/rl_chat_left"  

  28.         android:textSize="10sp" />  

  29. </RelativeLayout>  


chat_listview_item_right.xml





[html]


  1. <?xml version="1.0" encoding="utf-8"?>  

  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  

  3.     android:layout_width="wrap_content"  

  4.     android:layout_height="wrap_content" >  

  5.     <ImageView  

  6.         android:id="@+id/avatar_chat_right"  

  7.         android:layout_width="wrap_content"  

  8.         android:layout_height="wrap_content"  

  9.         android:layout_alignParentRight="true"  

  10.         android:layout_alignParentTop="true"  

  11.         android:src="@drawable/avatar_default" />  

  12.     <RelativeLayout  

  13.         android:id="@+id/rl_chat_right"  

  14.         android:layout_width="wrap_content"  

  15.         android:layout_height="wrap_content"  

  16.         android:layout_toLeftOf="@+id/avatar_chat_right"  

  17.         android:background="@drawable/chat_right" >  

  18.     <TextView  

  19.         android:id="@+id/message_chat_right"  

  20.         android:layout_width="wrap_content"  

  21.         android:layout_height="wrap_content"  

  22.         android:maxWidth="160dip" />  

  23.     </RelativeLayout>  

  24.     <TextView  

  25.         android:id="@+id/sendtime_chat_right"  

  26.         android:layout_width="wrap_content"  

  27.         android:layout_height="wrap_content"  

  28.         android:layout_below="@id/rl_chat_right"  

  29.         android:layout_toLeftOf="@+id/avatar_chat_right"  

  30.         android:textSize="10sp"/>  

  31. </RelativeLayout>  





在adapter中判斷消息是發(fā)出的還是收到的:




[java]


  1. if(ce.isLeft()){  

  2.     convertView = inflater.inflate(R.layout.chat_listview_item_left, null);  

  3.       

  4. }else{  

  5.     convertView=inflater.inflate(R.layout.chat_listview_item_right, null);  

  6.   

  7. }  



別的都和以前的差不多,知道了原理其實挺簡單的。


 


該文章在 2013/2/25 14:27:24 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運作、調(diào)度、堆場、車隊、財務(wù)費用、相關(guān)報表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點,圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點晴WMS倉儲管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務(wù)都免費,不限功能、不限時間、不限用戶的免費OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved