在我的申請,我爲Text Message Body
提供各種Templates
,作爲spinner list items
,可以選擇和用戶可以把他們而不是鍵入message
,但問題是,當用戶打開菜單項選擇模板application crashes
。 Spinner
我已通過菜單項訪問alert dialog box
。應用程序在選擇微調項目時崩潰了嗎?
代碼對話框*
AlertDialog.Builder rdialog = new AlertDialog.Builder(MainActivity.this);
rdialog.setTitle("Select Message");
rdialog.setIcon(android.R.drawable.ic_input_get);
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
alertView = inflater.inflate(R.layout.rptsetting,null);
final Spinner fSpinner = (Spinner)alertView.findViewById(R.id.fSpinner);
String providers[] ={"Busy", "Good Morning", "In office"};
ArrayAdapter<String> adp = new ArrayAdapter<String> (MainActivity.this,android.R.layout.simple_spinner_dropdown_item,providers);
fSpinner.setAdapter(adp);
fSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> aparent, View arg1,
int pos, long arg3) {
String selectedItem = fSpinner.getSelectedItem().toString();
if(selectedItem.equals("Busy")){
body = "Currently Busy call again later, Thanks";
}
if(selectedItem.equals("Good Morning")){
body = "A very Good Morning, Have a nice day";
}
if(selectedItem.equals("In office")){
body = "Currently in office";
}
}
@Override
public void onNothingSelected(AdapterView<?> aparent) {
}
});
rdialog.setView(alertView);
rdialog.setNeutralButton("SUBMIT", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog rdialog1 = rdialog.create();
rdialog1.show();
我已經定義body
作爲全球String,它可以訪問由Sms Manager
使用它作爲郵件的正文被髮送。 Log Cat
在此先感謝!
發表您的logcat –
@ Simple Plan的檢查我的編輯日誌貓 –
@什麼是身體?是一個字符串?然後初始化它。 –