내 응용 프로그램에서 에 대해 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();
나는 그것이 전송되는 메시지의 본문으로 사용하는 Sms Manager
에 의해 액세스 할 수 있도록 글로벌 문자열로 body
을 정의했습니다. 로그 고양이
미리 감사드립니다.
은 심플 플랜 @ 당신의 로그 캣 –
로그 고양이 –
내 편집을 확인 게시 @A 몸이란 무엇인가? String인가? 그것을 초기화했다. –