0
我有一個活動,其中包含微調和微調有一些項目的名稱,我想發送項目名稱到服務器是由用戶選擇,爲此我必須作出條件是否用戶選擇項目或不從微調,如果沒有選擇然後要顯示敬酒消息,如果選擇再發送該項目名稱server.How我能做到這一點如何在Android中檢查微調框是否爲空狀態?
這裏是活動的包含所有項目名單
public class CRechargeOperatorList {
public static final COperatorStorage item[] =
{
new COperatorStorage("Select Operator", null),
new COperatorStorage("Aircel", "AIRCEL"),
new COperatorStorage("BSNL", "BSNL"),
new COperatorStorage("Idea", "IDEAS"),
};
} 這裏是代碼包含Spinner的MainActivity的代碼
m_OperatorSpinner = (Spinner) m_Main.findViewById(R.id.operator_spinner);
ArrayAdapter<COperatorStorage> adapter = new ArrayAdapter<COperatorStorage>(getActivity(), R.layout.recharge_item, CRechargeOperatorList.item);
m_OperatorSpinner.setAdapter(adapter);
m_OperatorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
COperatorStorage operatorName = CRechargeOperatorList.item[position];
String selectedOperatorCode = operatorName.code;
Log.e(TAG, "Operator code:-" + selectedOperatorCode);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});