1

I would like to create a TextView which displays current application version.

Is it possible to use manifest data (in this case versionName attribute) in XML resource file to achieve this?

<TextView
    android:layout_width = "fill_parent"
    android:layout_height = "wrap_content"

    android:text = "(VERSION NAME)"
/>
Kao
  • 7,225
  • 9
  • 41
  • 65
  • it is possible only programatically – Blackbelt Sep 26 '15 at 10:06
  • possible duplicate of [How to get the build/version number of your Android application?](http://stackoverflow.com/questions/4616095/how-to-get-the-build-version-number-of-your-android-application) – Kao Sep 26 '15 at 10:17

1 Answers1

0

I have not tested but try this:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="?android:attr/versionName"
     />
    <!-- or -->
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="?android:attr/versionCode"
     />

If it doesnt the only solution is to use it programmatically

context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;

or use data from strings.xml in AndroidMainfest.xml file.

Community
  • 1
  • 1
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194