public class ListViweActivity extends Activity {
LinearLayout m_LinearLayout = null;
ListView m_ListView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
m_LinearLayout = new LinearLayout(this);
m_LinearLayout.setOrientation(LinearLayout.VERTICAL);
m_LinearLayout.setBackgroundColor(Color.BLACK);
m_ListView = new ListView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
m_LinearLayout.addView(m_ListView, params);
setContentView(m_LinearLayout);
//获取数据库Phones的Cursor
Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
startManagingCursor(cur);
ListAdapter adapter = new SimpleCursorAdapter(this,
// 定义List中每一行的显示模板
// 表示每一行包含两个数据项
android.R.layout.simple_list_item_2,
// 数据库的Cursor对象
cur,
// 从数据库的NAME和NUMBER两列中取数据
new String[] { PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER },
// 与NAME和NUMBER对应的Views
new int[] { android.R.id.text1, android.R.id.text2 });
m_ListView.setAdapter(adapter);
}
}运行的时候,这ListAdapter adapter = new SimpleCursorAdapter(...) Caused by: java.lang.IllegalArgumentException: column 'number' does not exist
是什么原因呢
解决方案 »
- 有工具能挡住TOAST的弹出的提示吗
- Camera4.0.3导入eclipse-------有android4.0.3源码朋友帮帮忙
- 怎么适应不同分辨率
- 构建一个Android阅读项目
- ******【android调用WCF接口Get Post方式还有ref参数的配置】******
- 银联手机支付SD卡 MAC计算
- android的opengl es的几个问题
- android--ImageView(context)的疑问?
- android新浪微博客户端授权问题
- android webView 播放视频,面板中的下载按钮如何去除。
- 问题:将SurfaceView对象和ImageView对象加载到一个布局对象中时,ImageView对象不能显示。
- android 检测运营商
android.R.layout.simple_list_item_2, cur,
new String[] { PhoneLookup.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER },
new int[] { android.R.id.text1, android.R.id.text2 });