Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当我们使用服务时,如何基于另一个微调器的选定值获取一个微调器的值_Java_Android_Service_Android Spinner - Fatal编程技术网

Java 当我们使用服务时,如何基于另一个微调器的选定值获取一个微调器的值

Java 当我们使用服务时,如何基于另一个微调器的选定值获取一个微调器的值,java,android,service,android-spinner,Java,Android,Service,Android Spinner,在我的应用程序中,我正在使用微调器。我希望基于对另一个微调器的项目的选择来获取一个微调器的值。我搜索了很多,但只找到了自定义数据。但我从服务中获得了这些微调值,所以有人能帮我解决这个问题 这是我的密码: //部门微调器 纺纱机; 字符串URL=”http://182.18.163.38/def.php?issue=1"; ArrayList部门; 字符串uid; //缺陷类旋转器 喷丝器喷丝器2; 字符串URL2=”http://182.18.163.38/def.php?issue=2&dep

在我的应用程序中,我正在使用微调器。我希望基于对另一个微调器的项目的选择来获取一个微调器的值。我搜索了很多,但只找到了自定义数据。但我从服务中获得了这些微调值,所以有人能帮我解决这个问题

这是我的密码:

//部门微调器
纺纱机;
字符串URL=”http://182.18.163.38/def.php?issue=1";
ArrayList部门;
字符串uid;
//缺陷类旋转器
喷丝器喷丝器2;
字符串URL2=”http://182.18.163.38/def.php?issue=2&dept=“+uid;
Arraylist缺陷;
字符串定义;
//分队干事纺纱工
喷丝器喷丝器3;
字符串URL3=”http://182.18.163.38/def.php?issue=3";
ArrayList BranchOfficer;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.new_缺陷);
//部门旋转器
Department=newarraylist();
微调器=(微调器)findViewById(R.id.select\u部门);
加载SpinnerData(URL);
spinner.setOnItemSelectedListener(新的AdapterView.OnItemSelectedListener(){
@凌驾
已选择公共视图(AdapterView AdapterView、View视图、int i、long l){
String department=spinner.getItemAtPosition(spinner.getSelectedItemPosition()).toString();
Toast.makeText(getApplicationContext(),department,Toast.LENGTH_LONG.show();
}
@凌驾
未选择公共无效(AdapterView AdapterView){
//在这里什么也不做
}
});
//缺陷纺纱机
缺陷=新的ArrayList();
喷丝头2=(喷丝头)findViewById(R.id.U类);
负荷纺锤体缺陷(URL2);
spinner2.setOnItemSelectedListener(新AdapterView.OnItemSelectedListener()){
@凌驾
已选择公共视图(AdapterView AdapterView、View视图、int i、long l){
字符串缺陷=spinner2.getItemAtPosition(spinner2.getSelectedItemPosition()).toString();
Toast.makeText(getApplicationContext(),缺陷,Toast.LENGTH_LONG.show();
}
@凌驾
未选择公共无效(AdapterView AdapterView){
//在这里什么也不做
}
});
}  
私有void loadSpinnerData(字符串url){
试一试{
HttpClient HttpClient=新的DefaultHttpClient();
HttpGet httpPost=新的HttpGet(url);
HttpResponse response=httpClient.execute(httpPost);
HttpEntity=response.getEntity();
字符串responseString=EntityUtils.toString(实体);
JSONArray JSONArray=新JSONArray(responseString);
for(int i=0;i
上面是我从url获取值的代码。

使用,而不是在主线程中执行网络操作

首先调用web服务为第一个微调器加载数据,在asynctask的onPostExecute()中填充数据

在第一个微调器的setOnItemSelectedListener中,从第一个微调器(我相信您正在这样做)和c获取所有异步任务的输入,以加载第二个微调器。您没有在第一个微调器的setOnItemSelectedListener中加载第二个微调器