SQL データベースに接続されているアプリがありListView
ます... CardsUI を使用するようにアプリを更新したいhttps://github.com/nadavfima/cardsui-for-android
このコードは今まで正常に動作していました:
public boolean onContextItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case DONE_ID:
AdapterContextMenuInfo infod = (AdapterContextMenuInfo) item
.getMenuInfo();
long infodId = infod.id;
Cursor items = dbAdapter.getMyItem(infodId);
startManagingCursor(items);
String title = items.getString(items
.getColumnIndexOrThrow(DbAdapter.KEY_TITLE));
String description = items.getString(items
.getColumnIndexOrThrow(DbAdapter.KEY_DESCRIPTION));
int priority = items.getInt(items
.getColumnIndexOrThrow(DbAdapter.KEY_PRIORITY));
dbAdapter.updateList(infodId, priority, title,
description);
return true;
case EDIT_ID:
AdapterContextMenuInfo idInfo = (AdapterContextMenuInfo) item
.getMenuInfo();
long idInfolong = idInfo.id;
Intent i = new Intent(this, Detail.class);
i.putExtra(DbAdapter.KEY_ROWID, idInfolong);
startActivityForResult(i, ACTIVITY_EDIT);
return true;
}
return super.onContextItemSelected(item);
}
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
menu.add(0, EDIT_ID, 0, R.string.menu_edit);
menu.add(0, DONE_ID, 0, R.string.menu_done);
}
このコードをカードで使用するにはどうすればよいですか? それは常にクラッシュします。SQL カーソルを管理すると、MySQL に接続されると読みました。内部のレコードの ID を取得するにはどうすればよいonContextItemSelected
ですか?
これは私のlogcat出力です:
10-22 19:28:37.213: E/AndroidRuntime(3087): FATAL EXCEPTION: main
10-22 19:28:37.213: E/AndroidRuntime(3087): Process: com.myapp.mylist, PID: 3087
10-22 19:28:37.213: E/AndroidRuntime(3087): java.lang.NullPointerException
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.myapp.mylist.MainActivtiy.onContextItemSelected(MainActivity.java:395)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.app.Activity.onMenuItemSelected(Activity.java:2620)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:350)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.support.v7.app.ActionBarActivity.onMenuItemSelected(ActionBarActivity.java:155)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3864)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:741)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:884)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:941)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.widget.AdapterView.performItemClick(AdapterView.java:299)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2911)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.widget.AbsListView$3.run(AbsListView.java:3645)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.os.Handler.handleCallback(Handler.java:733)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.os.Handler.dispatchMessage(Handler.java:95)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.os.Looper.loop(Looper.java:136)
10-22 19:28:37.213: E/AndroidRuntime(3087): at android.app.ActivityThread.main(ActivityThread.java:5001)
10-22 19:28:37.213: E/AndroidRuntime(3087): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 19:28:37.213: E/AndroidRuntime(3087): at java.lang.reflect.Method.invoke(Method.java:515)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
10-22 19:28:37.213: E/AndroidRuntime(3087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
10-22 19:28:37.213: E/AndroidRuntime(3087): at dalvik.system.NativeStart.main(Native Method)