我有一個簡單的程序,我將微調器設置到某個位置。然後我調用第二個模塊,當我返回時,我重置了微調器。微調器顯示不顯示微調器值。當您點擊微調器時,它指向正確的值,但顯示的值不正確。事實上,它實際上是退步了。微調器顯示錯誤的值
我寫了下面這個簡單的程序來演示。只有當表單在具有至少1個其他元素的Linearlayout或TableLayout中具有微調器時纔會發生這種情況。
main.xml中
<?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>
next.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/id1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
/>
</LinearLayout>
main.java
package tt.zzz;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
public class main extends Activity {
@Override
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
fillSpinner();
Button btnGo = (Button) findViewById(R.id.btn);
btnGo.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) { Go(); } });
}
void Go() {
Intent i = new Intent(this, next.class);
startActivityForResult(i, 0);
}
public void fillSpinner(){
Spinner spin_test = (Spinner) findViewById(R.id.btnFour);
ArrayAdapter<CharSequence> myAdapter =
new ArrayAdapter<CharSequence>(
this,
android.R.layout.simple_spinner_item
);
myAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
myAdapter.add("Option 1");
myAdapter.add("Option 2");
myAdapter.add("Option 3");
spin_test.setAdapter(myAdapter);
spin_test.setSelection(1);
spin_test.setOnItemSelectedListener(
new Spinner.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?>
arg0,View arg1,int arg2,long arg3){
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
fillSpinner();
}
}
next.java
package tt.zzz;
import android.app.Activity;
import android.os.Bundle;
public class next extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
}
}
好吧,我想這和它沒有任何效果。顯示的微調器值在每個週期遞減,並且彈出的值仍然顯示正確的值,與收縮的微調器不同。 – miannelle 2010-10-17 21:08:53