Android 开发实例 个人理财工具 启动界面实现
2010-04-12 15:51:00 来源:WEB开发网/ >
< /LinearLayout >
在Adapter中的to 参数中,指定这些TextView 使用那些Cursor的值.
我的cursor 就是含有这些字段"rowid","name", "fee","sdate","desc" .
准备好这些,使用 lv.setAdapter(mAdapter)该方法就可以绑定了.
下面给出具体代码文件
Grid_bills.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-账单明细(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);
赞助商链接