Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 未调用onBindDialogView-为什么?_Android_Listpreference_Dialog Preference - Fatal编程技术网

Android 未调用onBindDialogView-为什么?

Android 未调用onBindDialogView-为什么?,android,listpreference,dialog-preference,Android,Listpreference,Dialog Preference,我正在尝试实现ListPreference的一个子类,当调用它的构造函数时(在显示它时),它被覆盖的onBindDialogView没有被调用 public MyListPreference(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub Log.v(TAG, "MyListPreference construct

我正在尝试实现ListPreference的一个子类,当调用它的构造函数时(在显示它时),它被覆盖的onBindDialogView没有被调用

  public MyListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    Log.v(TAG, "MyListPreference constructed.");
  }


  @Override
  protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    Log.v(TAG, "onBindDialogView called");    
  }
为什么会这样?我错过了什么

更新:我插入了一条日志消息,它也被调用了

只有没有被调用


为什么??调用此回调的条件是什么?

您的
onCreateDialogView()
返回什么<代码>onBindDialogView()。另外,
onbindialogview()
仅在实际显示首选项时才被调用。参考号:。具体请参见
showDialog()
方法


如果您只是从
onCreateDialogView()
返回超级实现,我怀疑它会返回
null

您在
onBindDialogView()
中试图做什么?@shoerat我正在尝试。我的
onCreateDialogView()
返回其
super.onCreateDialogView()
返回的内容:null。如何在不更改原始ListPreference视图/布局的情况下使其返回非null?我真的不想更改视图/布局中的任何内容。我真正想要的是获得原始ListPreference视图的句柄/引用。这有可能吗?如果是,怎么做+1&谢谢。似乎没有公共API来获取
ListView
的句柄,它位于
ListPreference
中。您确实有一个
DialogPreference#getDialog()
——您可以将它转换为
AlertDialog()
,从那里您可以执行
getListView()
,但这取决于许多实现细节,我不推荐使用它。我建议您创建一个自定义的
首选项
,在这里您可以完全控制内容视图。事实上,请看,但是您回答我的问题非常好,所以接受了+赏金。您如何控制所有对话框,并设置其方向(例如,为了支持RTL)?