public class PopUpDialog extends Dialog {


Context context;
private View customView;

public PopUpDialog(Context context) {
super(context);
this.context = context;
// TODO Auto-generated constructor stub
}
public PopUpDialog(Context context, int theme){
super(context, theme);
this.context = context;
LayoutInflater inflater= LayoutInflater.from(context);
customView = inflater.inflate(R.layout.mydialog, null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(customView);
}
@Override
public View findViewById(int id) {
// TODO Auto-generated method stub
return super.findViewById(id);
}
public View getCustomView() {
return customView;
}

}

customView = inflater.inflate(R.layout.mydialog, null);通过此语句获取view“指针”(借用C的术语),在新的Activity中实现调用自定义对话框中的控件。

顺便说一句,csdn的代码插入对浏览器支持真烂。

PopUpDialog newDialog = new PopUpDialog(MsgReView.this, R.style.MyDialog);
newDialog.setCanceledOnTouchOutside(true);

View view = newDialog.getCustomView();
TextView text1 = (TextView)view.findViewById(R.id.textViewTotal);
text1.setText("调查人数:5");

更多相关文章

  1. android EditText控件
  2. Android(安卓)中沉浸式状态栏实现
  3. Android文字跑马灯控件(文本自动水平滚动)
  4. android 动态设置控件大小
  5. Android(安卓)解决Handler在运行时加载报空指针异常
  6. Android复习(九)
  7. android事件分发机制一
  8. android : 背景透明的 Dialog
  9. lyricView--歌词显示控件

随机推荐

  1. android截取屏幕图片
  2. Android获取网络图片并显示的方法
  3. Error:Failed to resolve: com.android.s
  4. Android SDK官方下载地址及在线SDK网址
  5. 判断用户使用的是 Android 手机还是平板
  6. android keyboard keycode
  7. 企业级Android Application Activity管理
  8. android 使用vcard示例
  9. Android类型转换 积累
  10. android studio详细的编译错误提示