applibgroup / HarmonyOS-Knowledgebase

This repository contains code samples of HarmonyOS Training
Apache License 2.0
17 stars 6 forks source link

How to inflate a layout in HarmonyOS with given context and layout resource id? #28

Closed chiragbhatt3 closed 3 years ago

chiragbhatt3 commented 3 years ago

Query description

I am working on a HarmonyOS library where I have to inflate a layout with a given layout resource id: int layoutRes and context: Context context.

In android, the same thing is done using

LayoutInflater.from(context).inflate(layoutRes, this, true);

What is the alternative for HarmonyOS? image

Stackoverflow link :

https://stackoverflow.com/questions/68575080/how-to-inflate-a-layout-in-harmonyos-with-given-context-and-layout-resource-id

Additional information

Developer Platform: Windows DevEco Studio version: 2.1.0.303 SDK API version: 5 SDK version: 2.1.1.21 Device: Not required Device OS version: Not required

Regards, Chirag

Meknaj commented 3 years ago

LayoutScatter.getInstance(context).parse(layoutRes, this, true);