Break line in json string java

后端 未结 3 1180
失恋的感觉
失恋的感觉 2021-01-28 07:46

Don\'t know how to express myslef very well.As you see down in my code I have a String,an ArrayList of Strings and a spinner.

In my code I add the elements of my String

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 08:20

    Try below code.

     ArrayList spinnerAccounts = new ArrayList<>(); // I don't know the use of this ArrayList
     Spinner accounts = (Spinner)findViewById(R.id.accounts);
     ArrayAdapter adapter =
           new ArrayAdapter(this,android.R.layout.simple_spinner_item,spinnerAccounts);
     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
     accounts.setAdapter(adapter);
     spinnerAccounts.add("one");
     spinnerAccounts.add("two");
     spinnerAccounts.add("three");
     spinnerAccounts.add("four");
     adapter.notifyDataSetChanged();
    

    Add items you want to display in Spinner using spinnerAccounts.add("ACCOUNT_NAME") method.

    Hope It'll help you.

提交回复
热议问题