Android 如何在一个序列中调用两个函数,其中一个是截取函数?

Android 如何在一个序列中调用两个函数,其中一个是截取函数?,android,sqlite,function,sequence,android-volley,Android,Sqlite,Function,Sequence,Android Volley,我的代码中有两个函数,一个是截取函数,另一个是普通SQLite函数。我遇到的问题是执行的顺序。在我从截取函数得到响应之前,SQLite函数被称为已执行函数。如何延迟SQLite函数的执行,直到Volley将响应发送回来 up.setOnClickListener新建OnClickListener { @凌驾 公共视图v { //托斯佩克。 //Toast.makeTextactivity.getApplicationContext、toSpeak、Toast.LENGTH\u SHORT.sh

我的代码中有两个函数,一个是截取函数,另一个是普通SQLite函数。我遇到的问题是执行的顺序。在我从截取函数得到响应之前,SQLite函数被称为已执行函数。如何延迟SQLite函数的执行,直到Volley将响应发送回来

up.setOnClickListener新建OnClickListener { @凌驾 公共视图v { //托斯佩克。 //Toast.makeTextactivity.getApplicationContext、toSpeak、Toast.LENGTH\u SHORT.show; View parentView=View v.getParent; Drawable Drawable=up.getDrawable; ifdrawable.getConstantState.equalsup\u green.getConstantState { int postid=Integer.parseIntTextView parentView.findviewbydr.id.post\u id.getText.toString; 森德沃特波斯蒂德,俄罗斯; int points=db.getLocalPointspostid; } } };
这里的问题是sendVote,Volley函数,我想等待它的响应,然后执行对SQLite函数getLocalpoints的调用。但是,在来自Volley sendVote函数的响应到达之前,会首先调用getLocalPoints。

Volley有一个名为future的功能,您可以使用该功能在继续之前等待Volley调用。要使用它,请执行以下操作:

        final RequestFuture<string> future = RequestFuture.newFuture();
        final FileListRequest request = new FileListRequest(Request.Method.GET, theURL, future, future);
        queue.add(request);
        //WARNING: will block!
        final String response = future.get();

        // Proceed with your SQLLite code here....

我假设您将在异步任务中执行这些代码,否则您的UI将冻结…

立即检查编辑…,请告诉我一些解决方案。谢谢@CL。您必须从响应侦听器调用getLocalPoints。您能解释一下如何在我的问题中使用它吗?我对volley不熟悉,所以不太了解执行。显示调用volley函数的代码。它在sendVote方法中吗?是的,sendVote是我代码中的截击函数…getLocalPoints是sqlite函数。那么你能展示你的sendVote代码,也许还有你的响应侦听器吗?