我用retrofit android用数据库服务器, 问题是我在localhost上有一个数据库 https://i.stack.imgur.com/mdhOQ.png 我想创建一个数组,以便只在其中包含值 哪个是数字8的值旁边 这样arrayString包含makarona和asd而没有Other值 但这里是打印makarona和asd和null 我想要一个具有数字8的相应名称的数组 查看代码以查看arrayString并试图纠正我的代码
private void getAllMeal(final int id_) {
api = HttpApi.getInstance();
api.addHeader("Authorization", "MyT23");
// Get iteme from index number .....
getUsersCall = api.getService().getAllChatRooms4();
///----------------------------
getUsersCall.enqueue(new retrofit.Callback<List<Users>>(){
@Override
public void onResponse(retrofit.Response<List<Users>> response, Retrofit retrofit) {
user = response.body();
String [] arrayString = new String[user.size()];
int[] arrayInt = new int[user.size()];
for(int i=0; i<response.body().size(); i++) {
arrayInt[i] = user.get(i).fk_chef;
if(Arrays.asList(arrayInt).contains(id_)){
arrayString[i] = user.get(i).name;
}
Toast.makeText(chef_hello.this,"results names :"+arrayString[i],Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Throwable t) {
//dialog2.dismiss();
//Toast.makeText(chef_hello.this,"Error Throwable xx :",Toast.LENGTH_LONG).show();
// Toast.makeText(Regest_login.this, "XXX", Toast.LENGTH_LONG).show();
}
});
}
答案 0 :(得分:0)
所以你试图用http连接到Mysql?