作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
初看起来是这样的:
这是按下“编辑”时弹出的对话框 fragment ,我希望在关闭对话框 fragment 后在 Activity 中看到更改。
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.edit_profile_dialog, new LinearLayout(getActivity()), false);
editProfile = (EditText) view.findViewById(R.id.changeProfile);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
setupProgressDialog();
/*get value from Bundle*/
String editValue = getArguments().getString("value", "");
editProfile.setText(editValue);
String title = getArguments().getString("title", "");
builder.setTitle(title);
builder.setView(view);
builder.setCancelable(false);
builder.setPositiveButton("Ok!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/*edit the value in shared preference*/
sharedPref = getActivity().getSharedPreferences(getString(R.string.sharedPref), 0);
editor = sharedPref.edit();
editor.putString(getArguments().getString("saved", ""), editProfile.getText().toString());
editor.apply();
ID= sharedPref.getString("id", null);
access_token=sharedPref.getString("token",null);
//Start of AsyncTask after this
最佳答案
如果您只需要更新用户从对话框中输入的数据,则不必重绘整个布局。
您只能将用户名设置为相关的 TextView 并关闭对话框 fragment 。
TextView yourNameTextView = (TextView)findViewById(R.id.your_textview);
public void setNameToTextView(String name){
yourNameTextView.setText(name);
}
当用户点击 Ok 按钮时,您可以调用:
((YourActivity)getActivity).setText(input);
祝你好运。
关于android - 我希望在关闭对话框 fragment 后刷新/重绘 Activity 。我该如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37803024/
我是一名优秀的程序员,十分优秀!