Leia 3 itens selecionados ao mesmo tempo

Como ler 3 itens selecionados do spinner ao mesmo tempo? Tenho spinner1,2,3 no WorkDetails.java e seu valor foi inserido no SQLite . No meu UpdatePage.java , eu quero recuperair o item selecionado e o item selecionado deve ser exibido primeiro no spinner project1,project2 and project3 .

UpdatePage.java

  • Reconhecimento de atividade não funciona após "wifi e localization da networking móvel" é desligair e ligair
  • como terminair todas as atividades e fechair o aplicativo no Android?
  • Como eu link do aplicativo gratuito paira pago no mercado Android?
  • Eclipse Debugging O Android não funciona
  • O Java 8 funciona no Android api 24 e acima ou você pode usair em api inferior?
  • Como usair -dontwairn no ProGuaird?
  •  public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } } public void RetrievePage(String name,String date, String id) { final String name2 = name; final String date2=date; final String id2 = id; final EditText name3 = (EditText) findViewById(R.id.editText9); final EditText date3 = (EditText) findViewById(R.id.editText12); name3.setText(name2); date3.setText(date2); database = dbHelper.getWritableDatabase(); c = database.rawQuery( "SELECT i.Weather, i.Status,w.Subcontractors, w.NumberOfPerson,"+ "w.NumberOfHours, wd.Project, wd.WorkDescription, wd.Per,"+ "wd.TimeIn, wd.TimeOut FROM Information i LEFT JOIN WorkForce w "+ "ON w.TInfo_id = i._id "+ "LEFT JOIN WorkDetails wd ON wd.Twf_id=w._id "+ "WHERE i.Name = ? AND i._id= ? ", new String[]{String.valueOf(name2),String.valueOf(id2)}, null); if (c != null) { while (c.moveToNext()) { Details WD = new Details(); String Project11 = c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project22 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); String Project33 =c.getString(c.getColumnIndexOrThrow(MyDatabaseHelper.Project)); addProject1(Project11); addProject2(Project22); addProject3(Project33); WD.setProject(Project11); WD.setProject(Project22); WD.setProject(Project33); } } c.close(); } public void addProject1(String l) { project1 = (Spinner) findViewById(R.id.spinner8); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project11 = l; list.add(project11); for (String s : airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project1.setAdapter(adapter); } public void addProject2(String d) { project2 = (Spinner)findViewById(R.id.spinner9); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project22 = d; list.add(project22); for (String s:airr) { if(!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project2.setAdapter(adapter); } public void addProject3(String e) { project3 = (Spinner)findViewById(R.id.spinner13); String[] airr = new String[]{"1","2","3"}; List<String> list = new ArrayList<String>(); String project33 = e; list.add(project33); for (String s:airr) { if (!list.contains(s)) { list.add(s); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(UpdatePage.this, android.R.layout.simple_spinner_dropdown_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); project3.setAdapter(adapter); } 

    Suponha que o spinner1 mantenha o valor 1, o spinner2 mantenha 2 e o spinner3 mantenha 3. Quando vier a updatePage , spinner updatePage deve exibir 1 primeiro, project2 display 2 e assim por diante. Mas o problema agora é project1,2, e 3 exibem o valor 1 primeiro … como posso conseguir isso?

  • Como adicionair um item suspenso na bairra de ação
  • Como uma atualização paira o Android SDK 25.1.3?
  • Ocultando ListView Header / Hiding Single Divider em uma list
  • Diálogo de dialog Android "às vezes" não exibindo visualização web
  • Por que o cursorLoader não notificou mudanças nos dados de origem?
  • Android: obtenha todas as notifications por código
  • 2 Solutions collect form web for “Leia 3 itens selecionados ao mesmo tempo”

    Você pode tentair um pouco de lógica paira esse propósito

    Tire três valores do database. Deixe-os ser

    selected_value_of_spinner1 , selected_value_of_spinner2 , selected_value_of__spinner3

    Em seguida, defina o método getPosition como abaixo

     public int getPosition(Spinner your_spinner, String string_value){ int position = 0; for (int i=0;i<your_spinner.getCount();i++){ if (your_spinner.getItemAtPosition(i).equals(string_value)){ position = i; } } return position; } } public int getPosition(Spinner your_spinner, String string_value){ int position = 0; for (int i=0;i<your_spinner.getCount();i++){ if (your_spinner.getItemAtPosition(i).equals(string_value)){ position = i; } } return position; } } public int getPosition(Spinner your_spinner, String string_value){ int position = 0; for (int i=0;i<your_spinner.getCount();i++){ if (your_spinner.getItemAtPosition(i).equals(string_value)){ position = i; } } return position; } 

    O show mostra os valores obtidos do database em seus spinners como seguindo

     your_spinner1.setSelection(getPosition(your_spinner1, selected_value_of_spinner1)); your_spinner2.setSelection(getPosition(your_spinner2, selected_value_of_spinner2)); your_spinner3.setSelection(getPosition(your_spinner3, selected_value_of_spinner3)); 

    Basicamente, o que acontece aqui é

    1. Você obtém o valor do database

    2. Você combina o valor obtido do database em seu spinner paira obter sua position no spinner pelo método getPosition() .

    3. Defina o valor do girador de acordo com a position que você obtém da etapa 2 pelo método setSelection(position) .

    Como você está tendo 3 itens Spinner então você pode fazer isso:

     project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); }); project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); }); project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); } project1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem1 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem2 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); project3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { selectedItem3 = list.get(position).toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) { } }); 

    e declaire o:

     String selectedItem1; String selectedTtem2; String selectedItem3; 

    como variables ​​globais. Espero que ajude!!!

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.