Greetings
We need to create a filter, where the input is an array of strings, in the list we tick the necessary strings, then we return the array with the selected strings. I tried to implement it through another activation, but there were problems with returning the array to the first form. How can I fix this? Or, ideally, get rid of the second activation ...
Thank.
public class filter extends Activity implements OnClickListener { final String LOG_TAG = "myLogs"; String[] itemOwner; ListView lvMain; String[] names; String[] returnList; int i, j; /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filter); itemOwner = new String[getIntent().getExtras().getInt("itemCount")]; //хапаем из первого активити массив itemOwner = getIntent().getExtras().getStringArray("itemOwner"); lvMain = (ListView) findViewById(R.id.lvMain); // устанавливаем режим выбора пунктов списка lvMain.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); // Создаем адаптер, используя массив из файла ресурсов ArrayAdapter < String > adapter = new ArrayAdapter < String > (this, android.R.layout.simple_list_item_multiple_choice, itemOwner); lvMain.setAdapter(adapter); Button btnChecked = (Button) findViewById(R.id.btnChecked); btnChecked.setOnClickListener(this); names = itemOwner; } public void onClick(View arg0) { // пишем в лог выделенные элементы SparseBooleanArray sbArray = lvMain.getCheckedItemPositions(); returnList = new String[sbArray.size()]; for (int i = 0; i < sbArray.size(); i++) { int key = sbArray.keyAt(i); if (sbArray.get(key)) returnList[i] = names[key]; } Intent intent = new Intent(this, GraphPrintActivity.class); //пытаемся возвратить выбранные элементы intent.putExtra("returnList", returnList); // в ключ returnList пихаем наш массив intent.putExtra("returnListCount", returnList.length); startActivity(intent); } }