无法通过listview获得不同的项目点击获得不同的API数据
ApiAllEmailInterface apiInterface = (ApiAllEmailInterface) ApiEmailClient.getApi();
Call<EmailModel> call = apiInterface.getResult(email);
call.enqueue(new Callback<EmailModel>() {
@Override
public void onResponse(Call<EmailModel> call, Response<EmailModel> response) {
if (!response.isSuccessful()) {
return;
}
Log.d("result", "onResponse: " + response.body());
Log.d("result1", "onResponse1: " + response);
EmailModel model = response.body();
List<String> listContents = new ArrayList<String>(model.getContents().size());
String[] passwords = new String[model.getContents().size()];
for(int i=0;i<model.getContents().size();i++) {
passwords[i]=model.getContents().get(i).getPassword();
listContents.add(passwords[i]);
}
lvone.setAdapter((new ArrayAdapter<String>(getApplicationContext(), R.layout.listview_items, listContents)));
lvone.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String value = (String)parent.getItemAtPosition(position);
MainActivity ma = null;
ma.hitApi();
}
});
在onItemClick
中,如何使用我的MainActivity
类中的API响应,因为它是我的Login类,并且使用不同的密码,在我的主屏幕上,但是现在如何在listview中获取该登录API的响应在特定项目上单击?