【发布时间】:2015-03-16 15:41:29
【问题描述】:
我想获取用户在 DialogFragment 中的当前位置并将所有数据传递给 SQLite 数据库。在我的 DoInBackground 中,我得到了运行良好的当前位置
我想设置一个 long 和 lat 的 TextView,如何将值传递给我的 AysncTask 并返回到我的对话框
protected getLocation doInBackground(String... params) {
}
protected void onPostExecute(getLocation result) {
}
}
我想在外部类中传递值,以便我可以将数据放入 sql 中
public Dialog onCreateDialog(Bundle savedInstanceState){
final AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
text = (TextView) view.findViewById(R.id.insert_long);
text2 = (TextView) view.findViewById(R.id.insert_lat);
build.setView(view);
db = new DBHelper(getActivity());
db.open();
build.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}
});
【问题讨论】:
-
我不是 100% 确定您的要求。是否要从 AsyncTask 返回位置?如果是这样,您可以将 AsyncTask 的返回类型从
String... params更改为Location... params -
我想返回 long 和 lat 以便我可以将它们设置为 TextView 并通过 onClick 将它们存储到 SQLite 中。 db.insert() 是我的 DBhelper 中的一个方法
-
你能发布你如何调用你的 asynctask 的代码吗?
-
我已经更新了我的代码
-
@Mark - 这不是完整的代码,因为我在您的
LocationTaskexecute() 上找不到行,control是什么?
标签: android android-asynctask android-dialogfragment android-location