How add layout ID to Android app?

  • I need Android layout ID to create View in Java code. In this code I use:

    myView = inflater.inflate(R.layout.main_activity, null);

    But main_activity is not known in Qt application. I created file android/res/layout/main_activity.xml in application project directory:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android=""

    And added it to .pro file

    DISTFILES += android/res/layout/main_activity.xml

    But compiler still gives error: error: cannot find symbol
        [javac]         myView = inflater.inflate(R.layout.main_activity, null);
        [javac]                                           ^
        [javac]   symbol:   variable main_activity
        [javac]   location: class layout

    How can I create layout ID solve my task? Or may be I can use another predefined ID for inflater? Which one?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.