我希望你能提供帮助/建议 我为我的GF写了一个简单的移位计算,我愚蠢地同意移植到她的phone.phone。我进入Android编码3天,所以对我很温柔:))
Shift calc有4个微调器 SOSH - 轮班时间的开始 SOSM - 分钟 EOSH - 轮班时间结束 EOSM - 分钟
我甚至不确定我是否过度复杂化了我需要的东西:
用户从微调器中选择4个值,我将传递给joda时间进行计算。
到目前为止,我有一个微调器SOSH工作并通过将字符串传递给textview进行测试,一切都很好。 SO添加了SOSM,现在有两个听众引起了问题。
我甚至需要这个,因为我不在乎更换微调器时,我只需要在按下按钮后检索值。
继承人我所拥有的 - 任何建议都非常欢迎
// SOSH和SOSM微调器的代码*************************************** ************************************************** *****************************************
Spinner spinnerSOSH = (Spinner) findViewById(R.id.spinnerSOSH);
Spinner spinnerSOSM = (Spinner) findViewById(R.id.spinnerSOSM);
ArrayAdapter<CharSequence> adapterSOSH = ArrayAdapter.createFromResource(this, R.array.StringArraySOSH,android.R.layout.simple_spinner_item);
adapterSOSH.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerSOSH.setAdapter(adapterSOSH);
ArrayAdapter<CharSequence> adapterSOSM = ArrayAdapter.createFromResource(this, R.array.StringArraySOSM,android.R.layout.simple_spinner_item);
adapterSOSM.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerSOSM.setAdapter(adapterSOSM);
spinnerSOSH.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()); // error: Error:(41, 47) error: OnItemSelectedListener is abstract; cannot be instantiated
spinnerSOSM.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
//执行SOSH的字符串转换并存储在SOSH字符串
中 Spinner spinnerSOSH = (Spinner) findViewById(R.id.spinnerSOSH);
String SOSHString = spinnerSOSH.getSelectedItem().toString();
//Do the string conversion for SOSM and store in SOSM string
Spinner spinnerSOSM = (Spinner) findViewById(R.id.spinnerSOSM);
String SOSMString = spinnerSOSM.getSelectedItem().toString();
@Override
void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// error : Error:(61, 18) error: onItemSelected(AdapterView<?>,View,int,long) in <anonymous com.welfareindustries.jennisshiftcalc2.MainActivity$1> cannot implement onItemSelected(AdapterView<?>,View,int,long) in OnItemSelectedListener
//attempting to assign weaker access privileges; was public
//////////////// taost message the value///////////////
Toast.makeText(parent.getContext(),
"On Item Select : \n" + parent.getItemAtPosition(position).toString(),
Toast.LENGTH_LONG).show();
//change a text box to the value///////////////////
final TextView textView = (TextView) findViewById(R.id.StringValueText);
textView.setText(SOSMString);
/////////////////////////////////////////////// ////////////////////////////////////////////////// ///
答案 0 :(得分:0)
得到了它们,我知道我过度复杂了
Spinner spinnerSOSH = (Spinner)findViewById(R.id.spinnerSOSH);
String SOSHVal = spinnerSOSH.getSelectedItem().toString();
final TextView textView = (TextView) findViewById(R.id.SOSHText);
textView.setText(SOSHVal);
Spinner spinnerSOSM = (Spinner)findViewById(R.id.spinnerSOSM);
String SOSMVal = spinnerSOSM.getSelectedItem().toString();
final TextView textView1 = (TextView) findViewById(R.id.SOSMtext);
textView1.setText(SOSMVal);
Spinner spinnerEOSH = (Spinner)findViewById(R.id.spinnerEOSH);
String EOSHVal= spinnerEOSH.getSelectedItem().toString();
final TextView textView2 = (TextView) findViewById(R.id.EOSHText);
textView2.setText(EOSHVal);
Spinner spinnerEOSM = (Spinner)findViewById(R.id.spinnerEOSM);
String EOSMVal= spinnerEOSM.getSelectedItem().toString();
final TextView textView3 = (TextView) findViewById(R.id.EOSMText);
textView3.setText(EOSMVal);