gpt4 book ai didi

java - 如何获取 Activity 的 View ?

转载 作者:太空宇宙 更新时间:2023-11-03 11:47:39 25 4
gpt4 key购买 nike

<分区>

我有以下方法,我想显示一个 Snackbar。问题是,我没有 Activity view,而且我不知道如何获取它。在代码中,您会看到 Snackbar viewviewInflate_setup 但它不起作用。我知道它不起作用,因为这是我的 alertdialog View ,而不是我当前的屏幕。我已经尝试获取 root view 但随后 snackbar 显示在错误的位置(在这三个 android 按钮后面)。如何获取我的 Activity View

public void confirmPassword(){
final LayoutInflater inflateSetup = getLayoutInflater();
final View viewInflate_setup = inflateSetup.inflate(R.layout.inflate_setup, null);

AlertDialog.Builder alertSetup = new AlertDialog.Builder(this);
alertSetup.setView(viewInflate_setup);
final AlertDialog dialogSetup = alertSetup.create();
dialogSetup.show();

btnConfirmPassowod = (Button)viewInflate_setup.findViewById(R.id.btnConfirm);
btnConfirmPassowod.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
System.out.println("User has clicked the [confirm] button");
dialogSetup.setCancelable(false);
edtPassword3 = (EditText)viewInflate_setup.findViewById(R.id.edtPassword3);
SUpassword3 = edtPassword3.getText().toString();

final ParseUser beforeConfirmPassword = ParseUser.getCurrentUser();
ParseUser.logInInBackground(beforeConfirmPassword.getUsername(), SUpassword3, new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if(e==null){
//password confirmed, go to next setup
System.out.println("Password [" +SUpassword3+ "] and user [" +beforeConfirmPassword.getUsername()+ "] confirmed, go to setup");
dialogSetup.dismiss();
}else{
//passwords don't match
System.out.println("Password don't match: [" +SUpassword3 + "] USER [" +beforeConfirmPassword.getUsername()+ "]");
Snackbar.make(viewInflate_setup, "Wrong password. Try again.", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
dialogSetup.dismiss();
}
}
});
}
});
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com