我在我的应用程序中使用 2 个微调器,我想在我的按钮单击中执行此操作,例如在 Visual Studio 中这样
if ((spin1.text = "bla bla bla") && (spin2. text = "ho ho ho"))
{
text1.text = result;
}
你有什么想法在android中执行这个操作吗?谢谢。
用这个代码解决了!!
spin1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View seletedItem, int pos, long id)
{
Object item = parent.getItemAtPosition(pos);
value1 = item.toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
spin2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View selectedItem, int pos, long id)
{
Object item = parent.getItemAtPosition(pos);
value2 = item.toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void count(View v)
{
if(value1.equals("Depok") && value2.equals("Jakarta"))
{
hasil.setText("SUCCESS");
}
}