android - 是否以编程方式制作微调器

android - make a spinner or not pprogrammatically

这是在下面的 xml 布局中定义的微调器。

<Spinner
   android:id="@+id/spinner"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />

我正在使用 activity class 中的微调器,如下所示

void spinner(){
        spMem=(Spinner)findViewById(R.id.spinner);
        adapterMem=new ArrayAdapter<String>(this,R.layout.spinner_layout,R.id.txt,listItemsMem);
        spMem.setAdapter(adapterMem);
        spMem.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
        ........................

考虑到调用上述方法时,我如何才能使其不出现在用户视线中。

每个视图都有一个 setVisibility() 方法。您可以使用它来将视图的外观设置为 INVISIBLEGONEVISIBLE.