怎么自定义dialog样式
2017-11-07
展开全部
1、自定义Dialog
1
final Dialog dialog = new Dialog(this, R.style.Theme_dialog);
2、窗口布局
1
View contentView = LayoutInflater.from(this).inflate(R.layout.select_list_dialog,null);
3、把设定好的窗口布局放到dialog中
1
dialog.setContentView(contentView);
4、设定点击窗口空白处取消会话
1
dialog.setCanceledOnTouchOutside(true);
5、具体的操作
1
ListView msgView = (ListView)contentView.findViewById(R.id.listview_flow_list);
6、展示窗口
dialog.show();
例:
final Dialog dialog = new Dialog(this,R.style.Theme_dialog);
View contentView =LayoutInflater.from(this).inflate(R.layout.select_list_dialog, null);
dialog.setContentView(contentView);
dialog.setCanceledOnTouchOutside(true);
ListView msgView = (ListView)contentView.findViewById(R.id.listview_flow_list);
TextView titleText = (TextView)contentView.findViewById(R.id.title);
titleText.setText("请选择银行卡");
SelectBankCardDialogAdapter adapter =new SelectBankCardDialogAdapter(this, mBankcardList);
msgView.setAdapter(adapter);
msgView.setOnItemClickListener(newOnItemClickListener() {
@Override
public void onItemClick(AdapterViewparent, View view, int position, long id) {
//Toast.makeText(RechargeFlowToMobileActivity.this,
// position+"",0).show();
mSelectCard =mBankcardList.get(position);
String area = mSelectCard.getBank_card();
mCardNumberText.setText(area);
dialog.dismiss();
}
});
Button closeBtn = (Button)contentView.findViewById(R.id.close);
closeBtn.setClickable(true);
closeBtn.setOnClickListener(newView.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
以上就是在Android开发自定义dialog样式的方法和步骤,android很多的控件都提供了接口或者方法进行样式的定义和修改。
1
final Dialog dialog = new Dialog(this, R.style.Theme_dialog);
2、窗口布局
1
View contentView = LayoutInflater.from(this).inflate(R.layout.select_list_dialog,null);
3、把设定好的窗口布局放到dialog中
1
dialog.setContentView(contentView);
4、设定点击窗口空白处取消会话
1
dialog.setCanceledOnTouchOutside(true);
5、具体的操作
1
ListView msgView = (ListView)contentView.findViewById(R.id.listview_flow_list);
6、展示窗口
dialog.show();
例:
final Dialog dialog = new Dialog(this,R.style.Theme_dialog);
View contentView =LayoutInflater.from(this).inflate(R.layout.select_list_dialog, null);
dialog.setContentView(contentView);
dialog.setCanceledOnTouchOutside(true);
ListView msgView = (ListView)contentView.findViewById(R.id.listview_flow_list);
TextView titleText = (TextView)contentView.findViewById(R.id.title);
titleText.setText("请选择银行卡");
SelectBankCardDialogAdapter adapter =new SelectBankCardDialogAdapter(this, mBankcardList);
msgView.setAdapter(adapter);
msgView.setOnItemClickListener(newOnItemClickListener() {
@Override
public void onItemClick(AdapterViewparent, View view, int position, long id) {
//Toast.makeText(RechargeFlowToMobileActivity.this,
// position+"",0).show();
mSelectCard =mBankcardList.get(position);
String area = mSelectCard.getBank_card();
mCardNumberText.setText(area);
dialog.dismiss();
}
});
Button closeBtn = (Button)contentView.findViewById(R.id.close);
closeBtn.setClickable(true);
closeBtn.setOnClickListener(newView.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
以上就是在Android开发自定义dialog样式的方法和步骤,android很多的控件都提供了接口或者方法进行样式的定义和修改。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询