-1
嗨..這是我的代碼我想在我的微調中添加數值..但我不知道我是如何做到這一點的.. ex A + = 5 等待你的幫助如何在android中添加微調值
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
private Spinner spinner1, spinner2;
private Button f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addItemsOnSpinner2();
addListenerOnButton();
addListenerOnSpinnerItemSelection();
}
EditText e1 = (EditText) findViewById(R.id.o1);
Button m = (Button) findViewById(R.id.b22);
public void addItemsOnSpinner2() {
spinner2 = (Spinner) findViewById(R.id.spinner2);
List<String> list = new ArrayList<String>();
list.add("A+");
list.add("A");
list.add("B");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(dataAdapter);
spinner1 = (Spinner) findViewById(R.id.spinner1);
List<String> list1 = new ArrayList<String>();
list1.add("A+");
list1.add("A");
list1.add("B");
ArrayAdapter<String> dataAdapter1 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list1);
dataAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(dataAdapter1);
}
public void addListenerOnSpinnerItemSelection() {
spinner1 = (Spinner) findViewById(R.id.spinner1);
spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
}
public void addListenerOnButton() {
spinner1 = (Spinner) findViewById(R.id.spinner1);
spinner2 = (Spinner) findViewById(R.id.spinner2);
Button f=(Button)findViewById(R.id.button);
f.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int gr1=Integer.parseInt(e1.getText().toString());
Toast.makeText(MainActivity.this,
"OnClickListener : " +
"\nSpinner 1 : "+ String.valueOf(spinner1.getSelectedItem()) +
"\nSpinner 2 : "+ String.valueOf(spinner2.getSelectedItem()),
Toast.LENGTH_SHORT).show();
}
});
}
}
的printf( 「%d \ n」 個,42);/*問題又是什麼 ? */ 我不知道哪兒,我要補充誰在微調中添加值的代碼