查看图片点击第一个First Image,获取第二个second image的值我希望在点击回收器时获得微调器中的所有项ID 查看任何选定的项目,并从recyclerview列表中获取所有项目ID。
我的代码:
public class Assigned extends AppCompatActivity
{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.assign);
recyclerView = (RecyclerView) findViewById(R.id.cardList);
final LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
model_joblists = new ArrayList<>();
recyclerView.addOnItemTouchListener(
new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent intent = new Intent(getApplicationContext(), JobSubmission_First.class);
HashMap<String, String> selected_item = Item_List.get(position);
intent.putExtra("job_no",selected_item.get(JOB_NO));
intent.putExtra("job_description",selected_item.get(DESCRIPTION_NAME));
startActivity(intent);
}
})
);
getDataNew();
}
private void getDataNew()
{
String url = "http://10.54.103.8:4067/services/Webservices/joblisting";
HashMap<String, String> user = session.getUserDetails();
String token = user.get(SessionManager.KEY_TOKEN);
Log.e("token ", token);
final String role = user.get(SessionManager.KEY_ROLE);
Log.e("role", role);
String user_id = user.get(SessionManager.KEY_USERID);
Log.e("user_id", String.valueOf(user_id));
Map<String, String> params = new HashMap();
params.put(KEY_TOKEN, token);
params.put(KEY_ROLE, role);
params.put(KEY_ID, user_id);
JSONObject parameters = new JSONObject(params);
final ProgressDialog loading = ProgressDialog.show(this, "Loading Data", "Please wait...", false, false);
JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.POST, url, parameters, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response)
{
try {
String req = response.getString("err-code");
if (0 == Integer.parseInt(req)) {
Log.e("response mila", response.toString());
ParseData(response);
loading.dismiss();
}
}
catch (JSONException e)
{
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
//TODO: handle failure
}
});
jsonRequest.setRetryPolicy(new DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT))
Volley.newRequestQueue(this).add(jsonRequest);
}
private void ParseData(JSONObject Object)
{
try {
JSONArray jsonArray = Object.getJSONArray("job_details");
for (int m = 0; m < jsonArray.length(); m++) {
Model_joblist model_joblist= new Model_joblist();
JSONObject jsonObject = jsonArray.getJSONObject(m);
HashMap<String, String> item = new HashMap<String, String>();
String job=jsonObject.getString("job_no");
String jobdes=jsonObject.getString("job_description");
item.put(JOB_NO, jsonObject.getString(JOB_NO));
item.put(DESCRIPTION_NAME,jsonObject.getString(DESCRIPTION_NAME));
Item_List.add(item);
jobdesnext.add(jsonObject.getString("job_description"));
jobno_spineer.add(jsonObject.getString("job_no"));
Log.e("spineer value", jobno_spineer.toString());
model_joblists.add(model_joblist);
}
String from[]={JOB_NO,DESCRIPTION_NAME};
int to[]={R.id.textSpinner,R.id.jobdescription};
spinnerAdapter=new SimpleAdapter(getApplicationContext(),Item_List,R.layout.assign,from,to);
} catch (JSONException e) {
e.printStackTrace();
}
ContactAdapter adapter2 = new ContactAdapter(model_joblists);
recyclerView.setAdapter(adapter2);
}
}