0

I have a background service running, displaying some views as system_overlay to provide aditional information for the currently active app.

To configure the hud display i want to show the user another overlay view to change some parameters.

The point of using system_overlay for the settings view too is to not be the active activity. Otherwise the original activity for which I provide the information gets closed by the system sometimes while the settings view is displayed because this other app uses a very big amount of ram (Thats why I don't want to use an activity for the settings view)


The Problem: I want something like a TabHost with a ViewPager in my settings view but without having an activity.

And even if I get the ViewPager working I can't load the contents because they are currently only available as fragments.


The Question: From what i read, fragments don't work without an activity, so what would be the right way to accomplish something like this?

Fabian N.
  • 3,807
  • 2
  • 23
  • 46

1 Answers1

1

in your xml file which you want to inflate for your view,add these both in that xml layout instead of using other things for a tab view.

  <com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    app:pstsShouldExpand="true"
    app:pstsTextAllCaps="true"
    app:pstsIndicatorColor="#ff9900"
    android:textColor="#ffffff"
    android:textSize="14sp"
    app:pstsUnderlineColor="@android:color/white"
    android:layout_width="match_parent"
    android:layout_height="48dp">
</com.astuetz.PagerSlidingTabStrip>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white" />

in your gradle dependencies add this line:- compile 'com.astuetz:pagerslidingtabstrip:1.0.1'

try it,hope it will solve your problem.

Animesh Jena
  • 1,541
  • 1
  • 25
  • 44
  • Sry for not accepting your answer. I was looking for a solution without more external libraries and completle forgot this thread. – Fabian N. May 25 '16 at 21:25