如何从下拉菜单中获取值并在要发送的新消息正文中使用它们。
以下是我的代码,
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
// On selecting a spinner item
String label = parent.getItemAtPosition(position).toString();
// Showing selected spinner item
Toast.makeText(parent.getContext(), "You selected: " + label,
Toast.LENGTH_LONG).show();
}
String phoneNo = editPhoneNum.getText().toString();
String sms = editSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud) 在我用Application我发送文本短信SMS Manager.检查是否发送了消息我正在使用Toast.而不是Toast我想得到SMS Delivery Report.我正在尝试许多例子,但是,一个流程没有显示交付报告,如果我的余额为0时,我的代码中的短信发送我希望找到短信发送失败的发送报告,当我的余额为0时.
码:
String phoneNo = phno.getText().toString();
String smsBody = body.getText().toString();
//Selected Messages to report to 1909
{
try
{
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, smsBody, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent to: "+phoneNo,Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
//Error Occurred if No Messages Selected
Toast.makeText(getApplicationContext(),"SMS failed, please try again later!",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
帮我任何代码!
Thanx in Adavance !!
搜索很多,但没有找到正确的答案.我有一个AlertDialogbox显示Spinner下拉列表.万物工作正常,但在微调时单击下拉列表中background的颜色是dark grey和list item color是black.所以很难看到列表项.有没有办法将列表项颜色设置为白色,以便它是可见的.提前致谢
fSpinner = (Spinner)alertView.findViewById(R.id.fSpinner);
ArrayAdapter<String> adp = new ArrayAdapter<String> (MainActivity.this,android.R.layout.simple_spinner_dropdown_item,providers);
fSpinner.setAdapter(adp);
Run Code Online (Sandbox Code Playgroud)