1
사용자 지정 대화 상자를 만들어 하나의 표준 대화 상자를 만들어 나중에 한 줄만 만들면 표준으로 사용할 수 있습니다. 매개 변수를 사용하여 텍스트를 변경합니다. 대화 상자는 매우 단순하며 하나의 단추 만 있습니다.사용자 지정 대화 상자가 응답 대기
이제이 문제에 대해 다시 생각해 보니 좋은 생각이었습니다. 실제로 대화 상자가 표시 될 때까지 내 앱이 멈추길 원합니다. 어떻게 관리 할 수 있니? 대화 상자에 반환 유형을 지정 하시겠습니까? 아니면 더 좋은 방법이 있습니까?
내 대화 :
/**
* custom dialog
*
* @param mcontext use activityname.this
* @param title
* @param text
* @param button
*/
public void showDialog(Context mcontext, String title,String text, String button) {
// fonts
Typeface tf_hn = Typeface.createFromAsset(mcontext.getAssets(), "helveticaneue.ttf");
Typeface tf_hn_bold = Typeface.createFromAsset(mcontext.getAssets(), "helveticaneuebd.ttf");
Resources res = mcontext.getResources();
// custom dialog
final Dialog dialog = new Dialog(mcontext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //not the normal dialog title
dialog.setContentView(R.layout.view_dialog);
TextView tv_dialog_title = (TextView) dialog.findViewById(R.id.tv_dialog_title);
tv_dialog_title.setText(title);
tv_dialog_title.setTypeface(tf_hn_bold);
tv_dialog_title.setTextColor(res.getColor(R.color.white));
TextView tv_dialog_text = (TextView) dialog.findViewById(R.id.tv_dialog_text);
tv_dialog_text.setText(text);
tv_dialog_text.setTypeface(tf_hn);
tv_dialog_text.setTextColor(res.getColor(R.color.white));
Button dialogButton = (Button) dialog.findViewById(R.id.bt_dialog_button);
dialogButton.setTypeface(tf_hn_bold);
dialogButton.setText(button);
dialogButton.setTextColor(res.getColor(R.color.white));
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
하고 난 다음과 같이 사용할 수 있습니다 :
내가 "당신이 로그인"이있는 대화 상자를 보여주고 싶었다 때까지, 모든 괜찮 았는데dialogH.showDialog(LoginActivity.this, res.getString(R.string.txt_dialog_fout), res.getString(R.string.txt_dialog_not_connected),res.getString(R.string.txt_dialog_button));
(또는 디스플레이를 클릭 한 후 인 텐트를 시작하십시오. 누구 아이디어?
:
그리고
대화 상자를 구현하는 – invertigo