Android 如何使用arrayadapter?
我正在制作一个可以搜索“employee”表并返回结果的应用程序。如何使用阵列适配器执行此操作?我不熟悉安卓系统Android 如何使用arrayadapter?,android,arrays,sqlite,Android,Arrays,Sqlite,我正在制作一个可以搜索“employee”表并返回结果的应用程序。如何使用阵列适配器执行此操作?我不熟悉安卓系统 public class SimpleSearch extends Activity { /** Called when the activity is first created. */ protected SQLiteDatabase db; Intent intent = getIntent(); @Override public voi
public class SimpleSearch extends Activity {
/** Called when the activity is first created. */
protected SQLiteDatabase db;
Intent intent = getIntent();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
doMySearch(query);
}
}
public List<String> doMySearch(String query) {
List<String> result = new ArrayList<String>();
Cursor c = db.query(
"employee",
new String[] { "_id" }, // The column you want as a result of the Query
"firstName like '%?%' OR lastName like '%?%' OR officePhone like '%?%'", // The where-Clause of the statement with placeholders (?)
new String[] { query, query, query }, // One String for every Placeholder-? in the where-Clause
);
while (c.moveToNext()) {
result.add(c.getString(0));
}
c.close();
return result;
}
}
您不必使用阵列适配器,而是使用。如果您需要使用它的示例,可以查看。您不必使用阵列适配器,而是使用。如果您需要使用它的示例,可以查看。您应该使用ListActivity或ListFragment,并使用CursorAdapter填充它们。SimpleCursorAdapter是一个实现类
可以从DomainSearch方法返回的列表中填充CursorAdapter。您应该使用ListActivity或ListFragment,并使用CursorAdapter填充它们。SimpleCorsorAdapter是一个实现类
可以从DomainSearch方法返回的列表中填充CursorAdapter。您应该改用SimpleCursorAdapter!请检查此项:您应该改用SimpleCorsorAdapter!请检查这个:像这样的东西?public void doMySearchString查询{cursor=db.rawQuerySELECT{u id,firstName,lastName,title FROM employee WHERE firstName | | | | | | | | | | | | | | | | | | | | lastName LIKE?,新字符串[]{query,new int[]{R.id.firstName,R.id.lastName,R.id.title};setListAdapteradapter;}}}类似这样的内容?public void doMySearchString查询{cursor=db.rawQuerySELECT{u id,firstName,lastName,title FROM employee WHERE firstName | | | | | | | | | | | | | | | | | | | | lastName LIKE?,新字符串[]{query,新int[]{R.id.firstName,R.id.lastName,R.id.title};setListAdapteradapter;}