当前位置: 代码迷 >> Android >> 对话框点击确定后念改变主activity的控件属性没效果
  详细解决方案

对话框点击确定后念改变主activity的控件属性没效果

热度:81   发布时间:2016-05-01 10:33:22.0
对话框点击确定后想改变主activity的控件属性没效果
本帖最后由 henha2jiang 于 2013-06-19 19:05:10 编辑

class btn_registOnclick implements OnClickListener{
ProgressDialog r_Dialog;
LayoutInflater regist_Inflater = LayoutInflater.from(Fx.this);
final View registView = regist_Inflater.inflate(R.layout.regist, null);
AlertDialog registDlg = new AlertDialog.Builder(Fx.this).
                setTitle("请登录"). 
                setView(registView).
                setPositiveButton("确定",  new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton1) {
// TODO Auto-generated method stub
r_Dialog = ProgressDialog.show(Fx.this, "请等待...", "正在为您登录...",true);
new Thread(){
 public void run(){
 try{
 sleep(3000);
 }
 catch(Exception e){
 e.printStackTrace();
 }
 finally{
LayoutInflater regist_Inflater = LayoutInflater.from(Fx.this);
 View fxView = regist_Inflater.inflate(R.layout.activity_fx, null);
 fxView.findViewById(R.id.btn_login).setBackgroundColor(Color.BLACK);//其中R.id.btn_login是初始屏幕中的一个按钮未报错,但是背景没有变黑
 r_Dialog.dismiss();
                                 }
 }
 }.start();
                 }
 }).
 setNegativeButton("取消",null).
 create();
public void onClick(View v){
registDlg.show();//显示登录对话框
}
}
对话框 异常 Java android

------解决方案--------------------
 LayoutInflater regist_Inflater = LayoutInflater.from(Fx.this);                                     View fxView = regist_Inflater.inflate(R.layout.activity_fx, null);                                     fxView.findViewById(R.id.btn_login).setBackgroundColor(Color.BLACK);//其中R.id.btn

这个view没看到你用啊.
------解决方案--------------------
引用:
  相关解决方案