Android 微调器显示错误的值
我有一个简单的程序,其中我设置了一个旋转器的位置。然后我调用第二个模块,当我返回时,我重置微调器。微调器显示不显示微调器值。轻触微调器时,它指向正确的值,但显示的值不正确。事实上,它实际上已经下台了 我编写了以下简单的程序来演示。仅当表单在Linearlayout或TableLayout中具有至少1个其他元素的微调器时,才会发生这种情况 main.xmlAndroid 微调器显示错误的值,android,spinner,Android,Spinner,我有一个简单的程序,其中我设置了一个旋转器的位置。然后我调用第二个模块,当我返回时,我重置微调器。微调器显示不显示微调器值。轻触微调器时,它指向正确的值,但显示的值不正确。事实上,它实际上已经下台了 我编写了以下简单的程序来演示。仅当表单在Linearlayout或TableLayout中具有至少1个其他元素的微调器时,才会发生这种情况 main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent" android:layout_height="200dp"
android:text="Main Form" />
<LinearLayout android:id="@+id/widget43"
android:layout_width="320dp" android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btn" android:text="Button" android:textSize="16sp"
android:layout_width="160dp" android:layout_height="40dp" />
<Spinner
android:id="@+id/btnFour" android:textSize="16sp"
android:layout_width="160dp" android:layout_height="40dp" />
</LinearLayout>
</LinearLayout>
试着打电话
@Override
public void onStart()
{
super.onStart();
this.fillSpinner();
}
由于onCreate只调用了一次,所以要在每次更新微调器时都在其他地方刷新它。onStart()-尝试调用的适当位置
@Override
public void onStart()
{
super.onStart();
this.fillSpinner();
}
由于onCreate只调用了一次,所以要在每次更新微调器时都在其他地方刷新它。onStart()-适当的位置我会按照barmaley的建议做,除了添加以下内容:
@Override
public void onResume()
{
super.onResume();
fillSpinner();
}
之所以需要这样做,是因为您启动了另一个活动,因此此活动已暂停。我将按照barmaley的建议执行,只是添加以下内容:
@Override
public void onResume()
{
super.onResume();
fillSpinner();
}
之所以需要这样做,是因为您启动了另一个活动,因此此活动已暂停。在设置选择后,添加以下行:
myAdapter.notifyDataSetChanged();
选择后,添加以下行:
myAdapter.notifyDataSetChanged();
好的,我试过了,但没有任何效果。显示的微调器值在每个循环中都会向下递减,弹出的值仍然显示正确的值,这与折叠的微调器不同。好的,我尝试了这个,但没有任何影响。显示的微调器值在每个循环中都会向下递减,弹出的值仍然显示正确的值,这与折叠的微调器不同。