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

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

Android 開(kāi)發(fā)即時(shí)聊天工具 YQ :(六) 最近會(huì)話列表

admin
2013年2月25日 14:26 本文熱度 4659

實(shí)現(xiàn)的效果如圖:




RecentActivity:





[java]


  1. "FONT-SIZE: 14px">public class RecentActivity extends Activity{  

  2.     ListView listView;  

  3.     List chatEntityList=new ArrayList();  

  4.     String[] mes;  

  5.       

  6.     protected void onCreate(Bundle savedInstanceState) {  

  7.         super.onCreate(savedInstanceState);  

  8.         requestWindowFeature(Window.FEATURE_NO_TITLE);  

  9.         setContentView(R.layout.activity_recent);  

  10.          //注冊(cè)廣播   

  11.         IntentFilter myIntentFilter = new IntentFilter();   

  12.         myIntentFilter.addAction("org.yhn.yq.mes");  

  13.         registerReceiver(new MyBroadcastReceiver(), myIntentFilter);  

  14.           

  15.         listView = (ListView) findViewById(R.id.lv_recent);  

  16.         listView.setOnItemClickListener(new OnItemClickListener(){  

  17.             public void onItemClick(AdapterView arg0, View arg1, int position,  

  18.                     long arg3) {  

  19.                 //打開(kāi)聊天頁(yè)面   

  20.                 Intent intent=new Intent(RecentActivity.this,ChatActivity.class);  

  21.                 intent.putExtra("account", Integer.parseInt(mes[0]));  

  22.                 intent.putExtra("nick""");  

  23.                 startActivity(intent);  

  24.             }  

  25.         });  

  26.     }  

  27.   

  28.     //廣播接收器   

  29.     public class MyBroadcastReceiver extends BroadcastReceiver {  

  30.         @Override  

  31.         public void onReceive(Context context, Intent intent) {  

  32.             mes = intent.getStringArrayExtra("message");  

  33.             Toast.makeText(context, "收到["+Integer.parseInt(mes[0])+"]的消息:"+mes[1], Toast.LENGTH_SHORT).show();  

  34.             //更新最近會(huì)話列表, 檢測(cè)chatEntityList,防止同一個(gè)好友的消息出現(xiàn)多個(gè)會(huì)話實(shí)體   

  35.             Iterator it=chatEntityList.iterator();  

  36.             if(chatEntityList!=null && chatEntityList.size()!=0){  

  37.                 while(it.hasNext()){  

  38.                     RecentEntity re=(RecentEntity) it.next();  

  39.                     if(re.getAccount()==Integer.parseInt(mes[0])){  

  40.                         chatEntityList.remove(re);  

  41.                     }  

  42.                 }  

  43.             }  

  44.             chatEntityList.add(new RecentEntity(5, Integer.parseInt(mes[0]), mes[0]+"", mes[1],mes[2], false));  

  45.             listView.setAdapter(new RecentAdapter(RecentActivity.this, chatEntityList));  

  46.             unregisterReceiver(this);  

  47.         }  

  48.     }  

  49. }  

  50.   

RecentActivity中l(wèi)istview的Adapter:





[java]


  1. "FONT-SIZE: 14px">public class RecentAdapter extends BaseAdapter{  

  2.     private Context context;  

  3.     private List list;  

  4.     LayoutInflater inflater;  

  5.       

  6.     public RecentAdapter(Context context,List list){  

  7.         this.context = context;  

  8.         this.list = list;  

  9.         inflater = LayoutInflater.from(context);  

  10.     }  

  11.   

  12.     public View getView(int position, View convertView, ViewGroup root) {  

  13.         convertView = inflater.inflate(R.layout.recent_listview_item, null);  

  14.           

  15.         ImageView avatar=(ImageView) convertView.findViewById(R.id.iv_avatar_r);  

  16.         TextView nick=(TextView) convertView.findViewById(R.id.tv_nick_r);  

  17.         TextView content=(TextView) convertView.findViewById(R.id.tv_chat_content_r);  

  18.         ImageView isRead=(ImageView) convertView.findViewById(R.id.iv_tip_mes_r);  

  19.         TextView time=(TextView) convertView.findViewById(R.id.tv_time_r);  

  20.   

  21.         RecentEntity re=list.get(position);  

  22.         nick.setText(re.getNick());  

  23.         content.setText(re.getContent());  

  24.         isRead.setImageResource(R.drawable.tips_message);  

  25.         time.setText(re.getTime());  

  26.   

  27.         return convertView;  

  28.     }  

  29.     public int getCount() {  

  30.         return list.size();  

  31.     }  

  32.   

  33.     public Object getItem(int position) {  

  34.         return list.get(position);  

  35.     }  

  36.   

  37.     public long getItemId(int position) {  

  38.         return position;  

  39.     }  

  40. }  

  41.   


消息實(shí)體類(lèi),就不貼代碼了,很簡(jiǎn)單,你懂的







--------------------------------------------------分割線----------------------------------------------------------




完善了部分界面,以及一些細(xì)節(jié),


后臺(tái)運(yùn)行,


增加了用戶(hù)頭像(簡(jiǎn)易方式,暫不能自定義頭像),


用戶(hù)個(gè)人信息


。。。


具體就不說(shuō)了看圖吧:






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