码迷,mamicode.com
首页 > 移动开发 > 详细

Android AlertDialog去除黑边白边自定义布局(转)

时间:2015-04-10 10:56:16      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

LayoutInflater inflater = this.getLayoutInflater();
View view = inflater.inflate(R.layout.test_alertdialog_listview,null);
ListView lv = (ListView)view.findViewById(R.id.test_alertdialog_listview);
lv.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,datas));
lv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
alertdialog.dismiss();
Toast.makeText(TestAndroid.this, datas[position], Toast.LENGTH_LONG).show();
}
});
alertdialog = new AlertDialog.Builder(this)
// .setView(view);
.setItems(datas, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.create();
// 在此使用setview方法可以设置布局文件和alertdialog四周边框的距离,可以消除黑边框
alertdialog.setView(view, 0, 0, 0, 0);
alertdialog.show();

 

Android AlertDialog去除黑边白边自定义布局(转)

标签:

原文地址:http://www.cnblogs.com/zhangs1986/p/4413697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!