最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 個(gè)人理財(cái)工具五:顯示賬單明細(xì) 上

 更新時(shí)間:2016年08月30日 10:29:19   投稿:lqh  
本文主要介紹 Android 個(gè)人理財(cái)工具顯示賬單明細(xì),這里提供了示例代碼,和實(shí)現(xiàn)效果圖,幫助大家學(xué)習(xí)理解ListView的用法,有興趣的小伙伴可以參考下

前面我們已經(jīng)將每個(gè)月的收支明細(xì)存入到SQLite的數(shù)據(jù)表中,本文將實(shí)現(xiàn)從SQLite的數(shù)據(jù)表中取出這些數(shù)據(jù)顯示為賬單明細(xì)界面。

       下圖是最終的效果圖:

       在設(shè)計(jì)該界面時(shí)我考慮過(guò)好幾個(gè)方案。本來(lái)準(zhǔn)備使用一個(gè)gridview,因?yàn)橛X(jué)得名字很像我需要的東西??墒呛髞?lái)查了一些資料,并且做了點(diǎn)實(shí)驗(yàn),發(fā)現(xiàn)和我想象的有些差距。于是采用了目前這種方式。使用Listview。

       這個(gè)界面布局實(shí)際上很簡(jiǎn)單,就是上面一個(gè)表頭(Linearlayout),中間一個(gè)Listview,下面是一個(gè)腳注(Linearlayout)。

       如何實(shí)現(xiàn)listview其中內(nèi)容?這個(gè)主要就是要理解Adapter的用法。

       SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)

Java代碼

String[] from=new String[] {"rowid","name", "fee","sdate","desc" }; 
int[] to=new int[] { R.id.item1, R.id.item2,R.id.item3,R.id.item4,R.id.item5 }; 
SimpleCursorAdapter mAdapter=new SimpleCursorAdapter(this,R.layout.grid_items, cur,from, to); 
lv.setAdapter(mAdapter); 

       這里我們只需要準(zhǔn)備好view的樣式和cursor就可以了。

       例如本例中的

       R.layout.grid_items是

XML/HTML代碼

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="horizontal" android:layout_width="fill_parent" 
 android:layout_height="fill_parent"> 
 <TextView android:id="@+id/item1" android:layout_height="fill_parent" 
 android:layout_width="wrap_content" android:width="20dip" 
 /> 
 <TextView android:id="@+id/item2" 
 android:layout_height="fill_parent" 
 android:text="賬目" 
 android:width="60dip" android:layout_width="wrap_content"/> 
 /> 
 <TextView android:id="@+id/item3" 
 android:text="費(fèi)用(元)" 
 android:textSize="14dip" android:width="60dip" android:layout_width="wrap_content" 
 android:layout_height="fill_parent" android:textStyle="bold|italic" 
 /> 
 <TextView android:id="@+id/item4" 
 android:layout_height="fill_parent"  
 android:text="日期" 
 android:width="80dip" 
 android:layout_width="wrap_content" 
 /> 
 <TextView android:id="@+id/item5" 
 android:layout_height="fill_parent"  
 android:text="備注" 
 android:width="100dip" android:layout_width="wrap_content" 
 /> 
  
</LinearLayout> 

       在Adapter中的to 參數(shù)中,指定這些TextView使用那些Cursor的值。

       我的cursor就是含有這些字段"rowid","name","fee","sdate","desc"。

       準(zhǔn)備好這些,使用lv.setAdapter(mAdapter)方法就可以綁定了。

       下面給出具體代碼文件:

       Grid_bills.java

Java代碼

package com.cola.ui; 
import java.util.ArrayList; 
import java.util.HashMap; 
import java.util.List; 
import java.util.Map; 
import android.app.Activity; 
import android.database.Cursor; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.KeyEvent; 
import android.view.View; 
import android.widget.AbsoluteLayout; 
import android.widget.EditText; 
import android.widget.GridView; 
import android.widget.LinearLayout; 
import android.widget.ListView; 
import android.widget.SimpleCursorAdapter; 
import android.widget.TextView; 
public class Grid_bills extends Activity { 
 BilldbHelper billdb; 
 View sv; 
 EditText edit; 
 AbsoluteLayout alayout; 
 int a=10,b=10; 
 GridView grd; 
 
 TextView total; 
 
 protected GridView listHands = null ; 
 public void onCreate(Bundle icicle) { 
 super.onCreate(icicle); 
 setTitle("ColaBox-賬單明細(xì)(2008-11月)"); 
 
 setContentView( R.layout.grid_bills) ; 
 billdb = new BilldbHelper(this); 
 Cursor cur=billdb.getBills(); 
 ListView lv=(ListView)findViewById(R.id.listview); 
 String[] from=new String[] {"rowid","name", "fee","sdate","desc" }; 
 int[] to=new int[] { R.id.item1, R.id.item2,R.id.item3,R.id.item4,R.id.item5 }; 
 SimpleCursorAdapter mAdapter=new SimpleCursorAdapter(this,R.layout.grid_items, cur,from, to); 
 lv.setAdapter(mAdapter); 
  
 //getBillsTotal 
 total=(TextView)findViewById(R.id.totalitem); 
 total.setText(billdb.getBillsTotal("2008-11")); 
 } 

       grid_item.xml

XML/HTML代碼

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="vertical" 
 android:layout_height="fill_parent" android:layout_width="fill_parent"> 
<LinearLayout 
android:id="@+id/LinearLayout01" 
xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> 
 <LinearLayout android:id="@+id/layouthead" 
 android:background="#ffCded8b" android:layout_height="fill_parent" android:layout_width="fill_parent" android:focusable="true" android:clickable="true" android:focusableInTouchMode="true" android:keepScreenOn="true"> 
 <TextView android:id="@+id/item1" android:layout_height="fill_parent" 
 android:layout_width="wrap_content" android:width="20dip" 
 /> 
 <TextView android:id="@+id/item2" 
 android:layout_height="fill_parent" 
 android:text="賬目" 
 android:textStyle="bold" android:width="60dip" android:layout_width="wrap_content"/> 
 /> 
 <TextView android:id="@+id/item3" 
 android:text="費(fèi)用(元)" 
 android:textSize="14dip" android:textStyle="bold" android:width="60dip" android:layout_width="wrap_content" 
 android:layout_height="fill_parent"/> 
 <TextView android:id="@+id/item4" 
 android:layout_height="fill_parent"  
 android:text="日期" 
 android:textSize="14dip" android:textStyle="bold" android:width="80dip" android:layout_width="wrap_content" 
 /> 
 <TextView android:id="@+id/item5" 
 android:layout_height="fill_parent"  
 android:text="備注" 
 android:textSize="14dip" android:textStyle="bold" android:width="100dip" android:layout_width="wrap_content" 
 /> 
 </LinearLayout> 
 <View android:layout_width="fill_parent" android:layout_height="1dip" android:background="?android:attr/listDivider"/> 
 <LinearLayout android:id="@+id/layout" android:layout_width="wrap_content" android:layout_height="fill_parent" android:minHeight="372dip"> 
 
 <ListView android:id="@+id/listview" android:layout_height="fill_parent" android:layout_width="fill_parent"></ListView> 
</LinearLayout> 
 <LinearLayout android:id="@+id/layoutfoot" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" android:background="#ffCded8b"> 
  
 <TextView android:id="@+id/totalitem" 
 android:layout_height="fill_parent" 
 android:text="當(dāng)月收入:2009.33 支出:3000.87 小計(jì):-1000.9" 
 android:textStyle="bold" android:layout_width="fill_parent" /> 
 /> 
  
 </LinearLayout> 
 </LinearLayout> 
</ScrollView> 

       這次我在sqlite的sql上面遇到點(diǎn)麻煩,目前還沒(méi)搞定,就是我保存在數(shù)據(jù)庫(kù)中的費(fèi)用是int型,分為單位。我從數(shù)據(jù)庫(kù)中取出來(lái)是 select fee/100 from bills ;但是顯示的卻是取整后的數(shù)值。

       不知道正確語(yǔ)法應(yīng)該是什么樣子,后面我想拼成字符顯示應(yīng)該可以,我就試了 select fee/100||'' from bills;,這樣就可以在listview上面輸出小數(shù)??墒俏野l(fā)現(xiàn)999999.99/100 輸出卻是1000000。我在adb shell里面查詢還是999999.99,到了listview時(shí)就變成了1000000,我估計(jì)可能是Adapter 里面的字符取出來(lái)用了getString的方法。

              系列文章:

                       Android 個(gè)人理財(cái)工具六:顯示賬單明細(xì) 下

                       Android 個(gè)人理財(cái)工具五:顯示賬單明細(xì) 上

                       Android 個(gè)人理財(cái)工具四:添加賬單頁(yè)面 下

                       Android 個(gè)人理財(cái)工具三:添加賬單頁(yè)面 上

                       Android 個(gè)人理財(cái)工具二:使用SQLite實(shí)現(xiàn)啟動(dòng)時(shí)初始化數(shù)據(jù)

                       Android 個(gè)人理財(cái)工具一:項(xiàng)目概述與啟動(dòng)界面的實(shí)現(xiàn)

           以上就是關(guān)于顯示賬單明細(xì)的功能實(shí)現(xiàn),后續(xù)繼續(xù)添加相關(guān)功能,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • 深入Android MediaPlayer的使用方法詳解

    深入Android MediaPlayer的使用方法詳解

    本篇文章是對(duì)Android中MediaPlayer的使用方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • Android StepView實(shí)現(xiàn)物流進(jìn)度效果

    Android StepView實(shí)現(xiàn)物流進(jìn)度效果

    這篇文章主要為大家詳細(xì)介紹了Android StepView實(shí)現(xiàn)物流進(jìn)度效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android Q適配之IMEI替換為Android_id

    Android Q適配之IMEI替換為Android_id

    這篇文章主要介紹了Android Q適配之IMEI替換為Android_id,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Android實(shí)現(xiàn)兩臺(tái)手機(jī)屏幕共享和遠(yuǎn)程控制功能

    Android實(shí)現(xiàn)兩臺(tái)手機(jī)屏幕共享和遠(yuǎn)程控制功能

    在遠(yuǎn)程協(xié)助、在線教學(xué)、技術(shù)支持等多種場(chǎng)景下,實(shí)時(shí)獲得另一部移動(dòng)設(shè)備的屏幕畫(huà)面,并對(duì)其進(jìn)行操作,具有極高的應(yīng)用價(jià)值,本項(xiàng)目旨在實(shí)現(xiàn)兩臺(tái) Android 手機(jī)之間的屏幕共享與遠(yuǎn)程控制,需要的朋友可以參考下
    2025-04-04
  • Android App中使用Glide加載圖片的教程

    Android App中使用Glide加載圖片的教程

    這篇文章主要介紹了Android App中使用Glide加載圖片的教程,包括網(wǎng)絡(luò)和本地圖片的加載方法講解,以及圖片加載異常的調(diào)試辦法,需要的朋友可以參考下
    2016-04-04
  • 解析離線安裝Eclipse的Android ADT開(kāi)發(fā)插件的具體操作(圖文)

    解析離線安裝Eclipse的Android ADT開(kāi)發(fā)插件的具體操作(圖文)

    本篇文章是對(duì)離線安裝Eclipse的Android ADT開(kāi)發(fā)插件的具體操作進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • Android實(shí)現(xiàn)Window彈窗效果

    Android實(shí)現(xiàn)Window彈窗效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)Window彈窗效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • Android 自定義ListView示例詳解

    Android 自定義ListView示例詳解

    本文主要介紹Android 自定義ListView的知識(shí),這里整理了相關(guān)資料及實(shí)現(xiàn)示例代碼,和實(shí)現(xiàn)效果圖,有興趣的小伙伴可以參考下
    2016-09-09
  • Android用文件存儲(chǔ)數(shù)據(jù)的方法

    Android用文件存儲(chǔ)數(shù)據(jù)的方法

    這篇文章主要為大家詳細(xì)介紹了Android用文件存儲(chǔ)數(shù)據(jù)的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • Android接入U(xiǎn)SB掃碼模塊的方法

    Android接入U(xiǎn)SB掃碼模塊的方法

    這篇文章主要為大家詳細(xì)介紹了Android接入U(xiǎn)SB掃碼模塊的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09

最新評(píng)論

金坛市| 永济市| 泰兴市| 保定市| 明光市| 大安市| 桐庐县| 怀化市| 云浮市| 孟津县| 清流县| 卢湾区| 孙吴县| 宿迁市| 金华市| 鸡西市| 德惠市| 玉屏| 邢台县| 汉中市| 增城市| 永嘉县| 武乡县| 清水县| 平舆县| 建平县| 玉门市| 华宁县| 海门市| 乌兰县| 凤冈县| 揭西县| 朔州市| 湖北省| 历史| 五华县| 海淀区| 登封市| 蒲城县| 重庆市| 措勤县|