📜  如何将列表数据设置为 android spinner - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:44.948000             🧑  作者: Mango

代码示例1
// setting branch data in manually and load to spBranchName
        List branchList = new ArrayList<>();
        branchList.add("CHITTAGONG");
        branchList.add("DHAKA");

        ArrayAdapter branchListAdapter = new ArrayAdapter<>(getActivity(),
                android.R.layout.simple_spinner_item, branchList);
        branchListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spBranchName.setAdapter(branchListAdapter);