Android AlertDialog 方法setView(view,0,0,0,0)开发自定义对话
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 06:11 点击:次
如果使用
m_currDlg = new AlertDialog.Builder(m_activity).create();
m_currDlg.setView(textEntryView,0,0,0,0);
m_currDlg.show();
m_currDlg.setView(textEntryView,0,0,0,0);
m_currDlg.show();
则可以得到想要的自定义的dialog
此时就可以控制Dialog在按了OK或者cancel的显示还是消失了
LayoutInflater factory = LayoutInflater.from(m_activity);
final View textEntryView = factory.inflate(R.layout.dialog_edit_text, null);
final View textEntryView = factory.inflate(R.layout.dialog_edit_text, null);
EditText etCon = (EditText)textEntryView.findViewById(R.id.edittext_edit);
etCon.setText(strContent);
TextView tvCon = (TextView)textEntryView.findViewById(R.id.edittext_view);
m_btnConfirm = (Button)textEntryView.findViewById(R.id.plsBtnConfirm);
m_btnCancel = (Button)textEntryView.findViewById(R.id.plsBtnCancel);
etCon.setText(strContent);
TextView tvCon = (TextView)textEntryView.findViewById(R.id.edittext_view);
m_btnConfirm = (Button)textEntryView.findViewById(R.id.plsBtnConfirm);
m_btnCancel = (Button)textEntryView.findViewById(R.id.plsBtnCancel);
if (0 != strTitle.length())
tvCon.setText(strTitle);
m_currDlg = new AlertDialog.Builder(m_activity).create();
m_currDlg.setView(textEntryView);
m_currDlg.show();
View.OnClickListener clickListener = new View.OnClickListener(){
@Override
public void onClick(View v) {
long id = v.getId();
if(id == R.id.plsBtnConfirm){
EditText etPl = (EditText)textEntryView.findViewById(R.id.edittext_edit);
String str = etPl.getText().toString().trim();
boolean bValid = UtilFun.isInputTextValid(str);
if (!bValid)
{
showWarningDlg("",m_activity.getString(R.string.str_invalid_playlist));
}
else
{
boolean bDismiss = isPlaylistNameValid(str,NEWPLS_INPUT);
if(bDismiss == true) m_currDlg.cancel();
}
}else if(id ==R.id.plsBtnCancel){
m_currDlg.cancel();
}
}
};
m_btnConfirm.setOnClickListener(clickListener);
m_btnCancel.setOnClickListener(clickListener);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>