Android spinner populating using arraylist

前端 未结 2 914
温柔的废话
温柔的废话 2021-01-22 17:51

im to populate spinner using arraylist , and that arraylist actully holds data from the file having android application data stored already for t=my application, im pasting the

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 18:43

    Try to initialize your spinner adapter with array in constructor.

    String[] wee = list2.toArray(new String[list2.size()]);
    final String[] str={"Report 1","Report 2","Report 3","Report 4","Report 5"};
    ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(
             this, android.R.layout.simple_spinner_item, wee);
    spinnerArrayAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
    
    // Spinner spinYear = (Spinner)findViewById(R.id.spin);
    spin.setAdapter(spinnerArrayAdapter);
    

提交回复
热议问题