如何在Dialogbox中用cointainerviewId替换片段

时间:2017-10-04 22:13:37

标签: android android-fragments fragment android-dialog fragmentmanager

我必须用片段替换id,这是我的来源:

curl_setopt_array($curl, array(
      CURLOPT_CAINFO => MSA_CERT,
      CURLOPT_SSL_VERIFYPEER => true,
      CURLOPT_URL => "https://xspiint.kusto.windows.net/v1/rest/query",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "{\r\n  \"db\":\"DallasTelemetry\",\r\n  \"properties\":null,\r\n  \"csl\":\"MaelstromEvents | count\"\r\n}",
      CURLOPT_HTTPHEADER => array(
        "accept: */*",
        "accept-encoding: gzip, deflate",
        "accept-language: en-US,en;q=0.8",
        "authorization: Bearer ".$access_token,
        "cache-control: no-cache",
        "connection: keep-alive",
        "content-length: 30",
        "content-type: application/json;charset=UTF-8",
        "host: xspiint.kusto.windows.net:443",
      ),
    ));

面对问题:

 public void showEmojiDialog() {
    final Dialog dialog = new Dialog(MainActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.activity_check);
    mEditEmojicon1 = (EmojiconEditText) dialog.findViewById(R.id.editEmojicon1);
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.editEmojicon1, EmojiconsFragment.newInstance(false))
            .commit();
    Button dialogButton = (Button) dialog.findViewById(R.id.send_btn);
    dialogButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

}
  

引起:java.lang.IllegalArgumentException:找不到片段EmojiconsFragment {1f7f3e0d#0 id = 0x7f0d007c}的id 0x7f0d007c(com.sample.testapplication:id / editEmojicon1)的视图

我很难将ID getSupportFragmentManager() .beginTransaction() .replace(R.id.editEmojicon1, EmojiconsFragment.newInstance(false)) .commit(); 替换为R.id.editEmojicon1但是因为我在对话框中它没有得到它的观点。

以下是我想在对话框中显示的内容。

1 个答案:

答案 0 :(得分:0)

而不是getSupportFragmentManager()使用getChildFragmentManager()