Using listview in Android to achieve beautiful table effect
Here we want to use Android listview to display the stock market. The effect picture is as follows. Red indicates that the stock price rises and green indicates that the stock price falls.
Step 1: define color.xml as follows:
Step 4: define the layout file of listitem, stock_ list_ Item.xml is as follows:
This is because the header is always fixed at the top of the list during the scrolling process of the listview and will not disappear with the scrolling of the listview.
So far, the layout file is basically defined. Here is how to implement it in the code.
StockListActivity.java
Stocklistadapter.java
StockListItem.java
That's it. In this example, we draw lines to divide each cell through view. In addition, we can define different background colors to achieve similar effects through background colors. It's not difficult, so we don't write it.