Android personal financial tool 5: display on bill details

Previously, we have saved the monthly revenue and expenditure details into the SQLite data table. This paper will take these data from the SQLite data table and display them as the bill details interface.

The following figure is the final rendering:

I have considered several schemes when designing the interface. I was going to use a GridView because I thought the name was very similar to what I needed. But later, I checked some data and did some experiments, and found that there was a gap with what I thought. So the current method is adopted. Use listview.

The interface layout is actually very simple, that is, a header (linear layout) above, a listview in the middle, and a footnote (linear layout) below.

How to implement the contents of listview? This is mainly to understand the usage of the adapter.

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

Java code

Here, we only need to prepare the view style and cursor.

For example, in this example

R.layout. grid_ Items yes

XML / HTML code

In the to parameter in the adapter, specify which cursor values these textviews use.

My cursor contains these fields "ROWID", "name", "fee", "sdate", "desc".

Get these ready and use Lv The setadapter (madapter) method can be bound.

Specific code files are given below:

Grid_ bills. java

Java code

grid_ item. xml

XML / HTML code

This time I had some trouble with SQLite's SQL, but I haven't done it yet, that is, the cost I saved in the database is int type, divided into units. Select fee / 100 from bills from the database; However, it shows the rounded value.

I don't know what the correct syntax should look like. Later, I want to spell it into characters. I tried to select fee / 100|'' from bills;, In this way, you can output decimals on listview. But I found that the output of 999999.99/100 was 1000000. I still query 999999.99 in the ADB shell. When I get to listview, it becomes 1000000. I guess the getString method is used to get the characters in the adapter.

Series of articles:

Android personal financial tool 6: display bill details

Android personal financial tool 5: display on bill details

Android personal finance tool 4: add bill page

Android personal finance tool 3: add to the bill page

Android personal finance tool 2: use SQLite to initialize data at startup

Android personal finance tool I: Project Overview and implementation of startup interface

The above is about the realization of the function of displaying bill details. Continue to add relevant functions in the future. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>