av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

使用ListView顯示數(shù)據(jù)

效果圖

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),疊彩企業(yè)網(wǎng)站建設(shè),疊彩品牌網(wǎng)站建設(shè),網(wǎng)站定制,疊彩網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷(xiāo),網(wǎng)絡(luò)優(yōu)化,疊彩網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力。可充分滿(mǎn)足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專(zhuān)業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶(hù)成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

1、先定義item

 
 
 
 
  1.  
  2.  xmlns:Android="http://schemas.android.com/apk/res/android"   
  3.     android:orientation="horizontal"   
  4.     android:layout_width="fill_parent"   
  5.     android:layout_height="wrap_content"> 
  6.  
  7.    android:layout_width="80dip"   
  8.    android:layout_height="wrap_content" 
  9.    android:id="@+id/personid" 
  10.  />   
  11.  
  12.    android:layout_width="100dip" 
  13.    android:layout_height="wrap_content" 
  14.    android:id="@+id/name"   
  15. />    
  16.  
  17.    android:layout_width="fill_parent"   
  18.    android:layout_height="wrap_content"   
  19.    android:id="@+id/amount"   
  20.  /> 
  21.  

2、通過(guò)適配器把數(shù)據(jù)綁定到ListView中,點(diǎn)擊某一行數(shù)據(jù)顯示編號(hào)

方式一:

 
 
 
 
  1. List> data=new ArrayList>();   
  2.        for(Person person :persons){   
  3.          HashMap hashMap=new HashMap();  
  4.          hashMap.put("id", person.getPersonId());  
  5.          hashMap.put("name", person.getName());  
  6.          hashMap.put("amount", person.getAmount());   
  7.          data.add(hashMap);  
  8.  }   
  9. SimpleAdapter adapter=new SimpleAdapter(this,data,R.layout.item,new String[]{"id","name","amount"},new int[]{R.id.personid,R.id.name,R.id.amount});              listView.setAdapter(adapter);  
  10.  listView.setOnItemClickListener(new OnItemClickListener(){   
  11. @Override  
  12. public void onItemClick(AdapterView parent, View view,  
  13.    int position, long id) {   
  14.    ListView myListView=(ListView)parent;  
  15.    HashMap item=(HashMap)myListView.getItemAtPosition(position);  
  16.    Toast.makeText(DBActivity.this, item.get("id").toString() , Toast.LENGTH_SHORT).show();  
  17.     }  
  18.   }   
  19. ); 

方式二:用游標(biāo)的方式

 
 
 
 
  1. Cursor cursor=personService.getCursor(0, 15);        //要求字段中要有_id  設(shè)計(jì)表的時(shí)候的主鍵為_(kāi)id          
  2. SimpleCursorAdapter cursorAdapter=new SimpleCursorAdapter(this,R.layout.item,cursor,new String[]{"_id","name","amount"},new   int[]{R.id.personid,R.id.name,R.id.amount});    
  3. listView.setAdapter(cursorAdapter);    
  4. listView.setOnItemClickListener(new OnItemClickListener(){   
  5. /**   
  6.  * parent當(dāng)前所點(diǎn)擊的listview對(duì)象   
  7.  * view當(dāng)前所點(diǎn)擊的條目   
  8. */   
  9. @Override   
  10.  public void onItemClick(AdapterView parent, View view,  
  11.    int position, long id) {   
  12.    ListView myListView=(ListView)parent;  
  13.    Cursor data=(Cursor)myListView.getItemAtPosition(position);//根據(jù)位置移動(dòng)游標(biāo)  
  14.    int m=data.getInt(data.getColumnIndex("_id"));   
  15.    Toast.makeText(DBActivity.this, String.valueOf(m) , Toast.LENGTH_SHORT).show();  
  16.     }  
  17.   }  
  18. ); 

 【編輯推薦】

Android智能手機(jī)操作系統(tǒng)

SQL Server與Oracle數(shù)據(jù)庫(kù)鏡像對(duì)比

在Android應(yīng)用程序中使用Internet數(shù)據(jù)

在不同字符集的數(shù)據(jù)庫(kù)之間導(dǎo)入數(shù)據(jù)的方法


網(wǎng)站題目:使用ListView顯示數(shù)據(jù)
分享網(wǎng)址:http://uogjgqi.cn/article/coiphoc.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢(xún)/運(yùn)營(yíng)咨詢(xún)/技術(shù)建議/互聯(lián)網(wǎng)交流