Search code examples
androidpopup

Is it possible to add Custom class in to the popupWindow in Android


I am creating custom keyboard. This keyboard created with custom class without xml usage. This is purely customized class for Keyboard. I did not use xml. Now I want to add the custom class in to the popup.

instead View customView = layoutInflater.inflate(R.layout.popup,null); Can I use my Custom class?

My class will be like following:

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

I want to add my CustomKeyboard in popupWindow. Please give me some ideas for this issue.


Solution

  • Inflate view mean nothing but adding new view to the parent view. So we can directly add the view instead of inflating views.

    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.