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 动态设置控件大小
  2. Android文字跑马灯控件(文本自动水平滚动)
  3. lyricView--歌词显示控件
  4. Android的GridView控件点击图片变暗效果
  5. Android控件指定方向加边框
  6. Android控件布局属性大全
  7. Android之ListView控件

随机推荐

  1. ToggleButton
  2. Android 画椭圆
  3. 开发者必看|Android(安卓)8.0 新特性及开
  4. Maven Android Plugin
  5. android颜色代码
  6. 【Android】自定义权限
  7. Android 电量显示Widgets插件实现
  8. android FloatingActionButton
  9. android 调用摄像头
  10. Android(安卓)应用程序不能全屏显示