自定义 Dialog --- 仿照微信删除联系人界面
2015-07-14 22:36
706 查看
</pre>作为一个初学者,对好多界面都感兴趣。 所以就动手慢慢做,然后写为博客。第一个简单的例子就是仿照微信的删除联系人节目。<p></p><p></p><p>1: 先看布局文件(需要注意: 我的布局文件里好多参数都是写死的,只是举例说明。 )</p><p></p><p></p><pre name="code" class="html"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="${relativePackage}.${activityClass}" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="删除联系人" android:textColor="#000000" android:textSize="24dp" android:padding="15dp" /> </LinearLayout> <TextView android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:text="将联系人***删除,将同时删除与该联系人的聊天记录" android:textSize="20dp" android:textColor="#000000" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > <Button android:id="@+id/btn_cancle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="取消" android:textColor="#4682B4" android:background="#FFFFFF" android:layout_marginBottom="5dp" <span style="white-space:pre"> </span>android:layout_toLeftOf="@+id/btn_ok" /> <Button android:id="@+id/btn_ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="删除" android:layout_marginBottom="5dp" android:textColor="#FF0000" android:layout_marginRight="10dp" android:background="#FFFFFF" android:layout_alignParentRight="true" /> </RelativeLayout> </LinearLayout>
2:下面贴出Activity代码(我用的是一个button按下后, 会弹出删除联系人的dialog)
Button button = (Button)findViewById(R.id.btn_delete); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog = new Dialog(DeletePeopleActivity.this); LayoutInflater inflater = LayoutInflater.from(DeletePeopleActivity.this); View view = inflater.inflate(R.layout.activity_delete_people, null); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(view); dialog.show(); Button delteButton = (Button)view.findViewById(R.id.btn_ok); delteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(DeletePeopleActivity.this, "Delete!", 3000).show(); dialog.dismiss(); } }); Button canclyeButton = (Button)view.findViewById(R.id.btn_cancle); canclyeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(DeletePeopleActivity.this, "Cancle!", 3000).show(); dialog.dismiss(); } });
3: 最终效果图
相关文章推荐
- DWZ刷新dialog解决方法
- C#实现自定义双击事件
- MFC自定义消息的实现方法
- C#实现ProperTyGrid自定义属性的方法
- php自定义错误处理用法实例
- ThinkPHP中自定义目录结构的设置方法
- C#自定义事件及用法实例
- C#中使用IFormattable实现自定义格式化字符串输出示例
- MC Dialog js弹出层 完美兼容多浏览器(5.6更新)
- javascript 自定义常用方法第1/2页
- js Dialog 去掉右上角的X关闭功能
- jquery BS,dialog控件自适应大小
- jquery ui dialog实现弹窗特效的思路及代码
- 自定义jQuery插件方式实现强制对象重绘的方法
- JQUERY dialog的用法详细解析
- jQuery实现自定义checkbox和radio样式
- jquery自定义插件开发之window的实现过程
- jQuery实现自定义事件的方法
- jQuery创建自定义的选择器用以选择高度大于100的超链接实例
- jQuery实现dialog设置focus焦点的方法