在mi布局中我有3个微调器。每个都实现onItemSelectedListener。问题是当我在微调器2上选择一个选项(spinnerSwitches)时,微调器3(spinnerVQs)正在调整自身大小,我不希望这种情况发生。 我附上了活动代码,图片和xml布局
的活动:
public class CCHawkResourcesActivity extends Activity {
private Spinner spinnerTenants;
private Spinner spinnerSwitches;
private Spinner spinnerVQs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cchawk_resources);
vincularControles();
Sesion.setUsuarioActual(RetornaLogica.GetInstance().getIl().TraerUsuarios().get(0));
Tenant selectedTenant=new Tenant(Sesion.getUsuarioActual().getConfig().getSelectedTenant());
ArrayAdapter<Tenant> a=new ArrayAdapter<Tenant>(this,R.layout.spinner_dropdown_item,Sesion.getListaTenants());
a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTenants.setAdapter(a);
if(!selectedTenant.getNombre().equals(""))spinnerTenants.setSelection(a.getPosition(selectedTenant));
spinnerTenants.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View selectedView,int position, long id) {
Tenant t=((Tenant)spinnerTenants.getSelectedItem());
Switch selectedSwitch=new Switch(Sesion.getUsuarioActual().getConfig().getSelectedSwitch());
ArrayAdapter<Switch> b=new ArrayAdapter<Switch>(CCHawkResourcesActivity.this,R.layout.spinner_dropdown_item,t.getListaSwitch());
b.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerSwitches.setAdapter(b);
if(!selectedSwitch.getNombre().equals(""))spinnerSwitches.setSelection(b.getPosition(selectedSwitch));
spinnerSwitches.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View selectedView,int position, long id) {
Switch s=((Switch)spinnerSwitches.getSelectedItem());
VirtualQueue selectedVQ=new VirtualQueue(Sesion.getUsuarioActual().getConfig().getSeletedVQ());
ArrayAdapter<VirtualQueue> c=new ArrayAdapter<VirtualQueue>(CCHawkResourcesActivity.this,R.layout.spinner_dropdown_item,s.getListaVQ());
c.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerVQs.setAdapter(c);
if(!selectedVQ.getNombre().equals(""))spinnerVQs.setSelection(c.getPosition(selectedVQ));
spinnerVQs.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View selectedView,int position, long id) {}
@Override
public void onNothingSelected(AdapterView<?> arg0) {}
});
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {}
});
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {}
});
}
private void vincularControles(){
spinnerTenants=(Spinner)findViewById(R.id.spinnerTenants);
spinnerSwitches=(Spinner)findViewById(R.id.spinnerSwitches);
spinnerVQs=(Spinner)findViewById(R.id.spinnerVQs);
}
}
活动布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/extra_dark_grey"
android:orientation="vertical"
android:padding="20dp" >
<TextView
android:id="@+id/select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/select"
android:textColor="@color/skyblue"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="@+id/selectText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:text="@string/selectText"
android:textColor="#FFFFFF"
android:textSize="15sp" />
<Spinner
android:id="@+id/spinnerTenants"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="@string/select_tenant"
android:spinnerMode="dialog"/>
<Spinner
android:id="@+id/spinnerSwitches"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="@string/select_switch"
android:spinnerMode="dialog"/>
<Spinner
android:id="@+id/spinnerVQs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="@string/select_vq"
android:spinnerMode="dialog"/>
<ImageButton
android:id="@+id/btnPlus"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="right"
android:layout_weight="2"
android:background="#00000000"
android:onClick="continueToStats"
android:scaleType="fitEnd"
android:src="@drawable/conf_right" />
图片
答案 0 :(得分:0)
我解决了它,您需要做的是为每个包含微调器的线性布局建立一个高度,例如60p,并为每个微调器建立一个小于线性布局的高度,例如50dp