如何显示在我的飞旋我的通讯录数据库的价值?我的、通讯录、价值、数据库

2023-09-07 04:58:29 作者:坐在坟前调戏鬼i

在我的布局XML我有一个微调,在我的java我有一个数据库,联系人和它的一些价值观,所以我想知道我是怎么发或微调把这些值从数据库中,所以当我点击它,它选择的接触,code中的任何例子吗?

In my layout xml I have a spinner and in my java I have a database with contacts and some values on it so I want to know how I send or put these values from the database in the spinner so when I click it, it selects the contact, any example of code?

推荐答案

首先从数据库中的联系人的详细信息。您可以在 HTTP找到范例code数据库的概念:// codinglookseasy。 blogspot.in/2012/08/sqlite-database.html 。接下来,从你可能已经有对象的ArrayList,并设置使用的微调联系人姓名上面的示例

Get the contacts details from the database first. You can find a sample code for database concept at http://codinglookseasy.blogspot.in/2012/08/sqlite-database.html . Next from the above sample you may have got ArrayList of objects and set the contact names in the spinner using a

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(dataAdapter);

如果在此列出可能与您的ArrayList中从数据库中的数据。 (存储您想要从数据库显示到这个列表中的特定字段)。使用GET选择的项目

Where list here may be the data from your ArrayList from the database. (store a specific field that you want to display from the database into this list). Get the item selected using

spinner2.getSelectedItem() 

这给选择的项目,并得到了从数据库

which gives the item selected and get the data using from the ArrayList that you got from the database

 
精彩推荐
图片推荐