English 中文(简体)
2. 警惕
原标题:AlertDialog with a Cursor
  • 时间:2012-01-14 00:26:05
  •  标签:
  • android

我正在寻求一些帮助,了解警示迪亚洛的工作。 目前,我有一个工作方言,可以检索从Kumk数据库中挑选参与者的名单。 设想是用户从清单中挑选一个列入清单的参与者,我把这一名称储存在一个变量中。 下面的几句法典赋予我对名字的煽动立场。

return new AlertDialog.Builder(this)
.setCancelable(false)
.setTitle("Choose a Player")
.setSingleChoiceItems(dba.getAllPlayers(), -1, Constants.playerName, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {

***** get the name of the player selected ****
dialog.dismiss();
startMenu();
}
})
.create();

我需要yn子来指一位 cur子。 我理解,按照准则(http://developer.android.com/guide/topics/ui/dialogs.html),从这个阵列(项目[项目])中将选定项目列入一个更为基本的清单,但我如何将清单从我打电话到数据库?

Tried playerName = dba.getAllPlayers (.getString (item);,但我收到了“CursorIndexOutOfBoundsException: Index -1 requested,其大小为1”类型错误。

事先感谢,希望有人会给我带来一些光明。 乘客。

Glenn Aging Cobol Programmer Very New to Android

问题回答

如果是:

playerName = dba.getAllPlayers().getString(item);

请从<代码>Curs查询<编码>栏目中的示意图。 这当然没有任何意义。 你们需要的是要求采取立场,这样看得更好:

final Cursor cursor = dba.getAllPlayers()
.setSingleChoiceItems(cursor, -1, Constants.playerName, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {

cursor.moveToPosition(item);
String blah = cursor.getString(cursor.getColumnIndex(Constants.playerName));




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签