Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:19:24+00:00 2026-06-17T06:19:24+00:00

Hi I’m making this app with two fragments that you can swipe between. The

  • 0

Hi I’m making this app with two fragments that you can swipe between. The code compiles and runs without crashing and both tabs are shown and you can swipe between the tabs but the tabs have no content. I think this is a problem with the fragments trying to setcontentview. If you need anymore info just ask 🙂

my main activity

import java.util.ArrayList;

import org.holoeverywhere.app.Activity;
import org.holoeverywhere.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockActivity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.WindowManager;

public class SwipeTabsMainActivity extends Activity {
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
TextView tabCenter;
TextView tabText;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);

    setContentView(mViewPager);
    ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);

        mTabsAdapter.addTab(bar.newTab().setText("Stopwatch"),StopWatchFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Timer"), CountdownFragment.class, null);



}

public static class TabsAdapter extends FragmentPagerAdapter implements
        ActionBar.TabListener, ViewPager.OnPageChangeListener {
    private final Context mContext;
    private final ActionBar mActionBar;
    private final ViewPager mViewPager;
    private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();

    static final class TabInfo {
        private final Class<?> clss;
        private final Bundle args;

        TabInfo(Class<?> _class, Bundle _args) {
            clss = _class;
            args = _args;
        }
    }

    public TabsAdapter(Activity activity, ViewPager pager) {
        super(activity.getSupportFragmentManager());
        mContext = activity;
        mActionBar = activity.getSupportActionBar();
        mViewPager = pager;
        mViewPager.setAdapter(this);
        mViewPager.setOnPageChangeListener(this);
    }

    public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
        TabInfo info = new TabInfo(clss, args);
        tab.setTag(info);
        tab.setTabListener(this);
        mTabs.add(info);
        mActionBar.addTab(tab);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mTabs.size();
    }

    @Override
    public Fragment getItem(int position) {
        TabInfo info = mTabs.get(position);
        return Fragment.instantiate(mContext, info.clss.getName(),
                info.args);
    }

    @Override
    public void onPageScrolled(int position, float positionOffset,
            int positionOffsetPixels) {
    }

    @Override
    public void onPageSelected(int position) {
        mActionBar.setSelectedNavigationItem(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {
    }

    @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
        Object tag = tab.getTag();
        for (int i = 0; i < mTabs.size(); i++) {
            if (mTabs.get(i) == tag) {
                mViewPager.setCurrentItem(i);
            }

        }
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    }

    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft) {
    }
}
}

the Main Activity’s xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" />

my countdown timer fragment

import org.holoeverywhere.app.Fragment;
import org.holoeverywhere.internal._View;
import org.holoeverywhere.preference.PreferenceManager;
import org.holoeverywhere.preference.SharedPreferences;
import org.holoeverywhere.widget.Button;
import org.holoeverywhere.widget.TextView;
import org.holoeverywhere.widget.Toast;

import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import org.holoeverywhere.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Chronometer;
import android.widget.ImageButton;
import android.widget.Chronometer.OnChronometerTickListener;
import android.widget.RelativeLayout;

public class CountdownFragment extends Fragment implements
    OnChronometerTickListener {
TextView second, hour, minute;
ImageButton hourup, hourdown, minuteup, minutedown, secondup, seconddown;
Button start, stop;
int hourCount, minCount, secCount;
Context c;
Chronometer count;
boolean viberate, running;
Vibrator v;
boolean startstopshow;
SharedPreferences getPrefs;
View fv = getView();
RelativeLayout rl;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    initilize(c);
    setClicker();
    count.start();
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    c = getActivity();




}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.countdown, container, false);
     rl = (RelativeLayout )inflater.inflate(R.layout.countdown, container, false);

    return super.onCreateView(inflater, container, savedInstanceState);
}



private void initilize(Context c) {
    hourup = (ImageButton) rl.findViewById(R.id.hourup);
    minuteup = (ImageButton) rl.findViewById(R.id.minuteup);
    secondup = (ImageButton) rl.findViewById(R.id.secondup);
    hourdown = (ImageButton) rl.findViewById(R.id.hourdown);
    minutedown = (ImageButton) rl.findViewById(R.id.minutedown);
    seconddown = (ImageButton) rl.findViewById(R.id.seconddown);
    start = (Button) rl.findViewById(R.id.start);
    stop = (Button) rl.findViewById(R.id.stop);
    second = (TextView) rl.findViewById(R.id.second);
    minute = (TextView) rl.findViewById(R.id.minute);
    hour = (TextView) rl.findViewById(R.id.hour);
    hourCount = 0;
    minCount = 0;
    secCount = 0;

    count = (Chronometer) rl.findViewById(R.id.chronometer1);
    v = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
    running = false;
    getPrefs = PreferenceManager.getDefaultSharedPreferences(c);
}

@Override
public void onChronometerTick(Chronometer chronometer) {
    switch (chronometer.getId()) {

    case (R.id.chronometer1):
        secCount--;
        updateDisplay();
        break;
    }
}

}

my fragments xml file

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TableLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="56dp" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageButton
            android:id="@+id/hourup"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/up" />

        <ImageButton
            android:id="@+id/minuteup"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/up" />

        <ImageButton
            android:id="@+id/secondup"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/up" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <org.holoeverywhere.widget.TextView
            android:id="@+id/hour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00 : "
            android:textSize="35sp" />

        <org.holoeverywhere.widget.TextView
            android:id="@+id/minute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00 : "
            android:textSize="35sp" />

        <org.holoeverywhere.widget.TextView
            android:id="@+id/second"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00"
            android:textSize="35sp" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageButton
            android:id="@+id/hourdown"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/down" />

        <ImageButton
            android:id="@+id/minutedown"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/down" />

        <ImageButton
            android:id="@+id/seconddown"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/down" />
    </TableRow>
</TableLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_weight="50"
    android:gravity="bottom"
    android:weightSum="100" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true" >

        <org.holoeverywhere.internal._View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="4dip"
            android:layout_marginRight="4dip"
            android:background="?dividerVertical" />

        <org.holoeverywhere.internal._View
            android:id="@+id/ViewColorPickerHelper"
            android:layout_width="1dip"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="4dip"
            android:layout_marginTop="4dip"
            android:background="?dividerVertical" />

        <org.holoeverywhere.widget.Button
            android:id="@+id/start"
            style="@style/Holo.Button.Borderless"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/view1"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/stop"
            android:text="Start" />

        <org.holoeverywhere.widget.Button
            android:id="@+id/stop"
            style="@style/Holo.Button.Borderless"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/ViewColorPickerHelper"
            android:text="Stop" />
    </RelativeLayout>
</LinearLayout>

<Chronometer
    android:id="@+id/chronometer1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Chronometer"
    android:textSize="0px"
    android:visibility="invisible" />

</RelativeLayout>

screenshot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:19:25+00:00Added an answer on June 17, 2026 at 6:19 am

    I finally found the problem:

    You have to replace : super.onCreateView(inflater, container, savedInstanceState); to your countdown view :

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.countdown, container, false);
         rl = (RelativeLayout )inflater.inflate(R.layout.countdown, container, false);
    
        return  v;
    }
    

    Here’s a screenshot of the result:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.