【问题标题】:Is it possible to add Custom class in to the popupWindow in Android是否可以在 Android 的 popupWindow 中添加自定义类
【发布时间】:2022-10-18 14:57:17
【问题描述】:

我正在创建自定义键盘。该键盘使用自定义类创建,不使用 xml。这纯粹是为键盘定制的类。我没有使用xml。现在我想将自定义类添加到弹出窗口中。

取而代之的是View customView = layoutInflater.inflate(R.layout.popup,null); 我可以使用我的自定义类吗?

我的课程将如下所示:

public class CustomKeyboard extends LinearLayout {
//Creating layouts and buttons for Keyboard
}

我想在弹出窗口中添加我的自定义键盘。请给我一些关于这个问题的想法。

【问题讨论】:

    标签: android popup


    【解决方案1】:

    膨胀视图只是向父视图添加新视图。所以我们可以直接添加视图而不是膨胀视图。

    CustomKeyboard custKeyboard = new CustomKeyboard(context);
    //View customView = layoutInflater.inflate(R.layout.popup,null);//No need to use this.
    View customView = custKeyboard;// Instead we can use this.
    

    【讨论】:

      猜你喜欢
      • 2021-06-30
      • 1970-01-01
      • 2019-10-22
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2022-09-25
      • 1970-01-01
      相关资源
      最近更新 更多