ActionBar tabs with ViewPager and Frame Layout - android

I was wanting to use ActionBar tabs and ViewPager to implement swiping between tabs. I have successfully used the example here:
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
However, I also wanted to add a Frame Layout outside of the ViewPager in the xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
<FrameLayout
android:id="#+id/frame_layout"
android:name="com.banagas.calculator.ButtonFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
If I set the setContentView() to my layout with both the ViewPager and Frame Layout, the ViewPager stops functioning:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i("MainActivity", "onCreate");
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.FrameLayout1);
ActionBar bar = getSupportActionBar();
mViewPager.setOffscreenPageLimit(4);
bar.setDisplayHomeAsUpEnabled(false);
bar.setDisplayShowTitleEnabled(false);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mTabsAdapter = new TabsAdapter(this, mViewPager);
mTabsAdapter.addTab(bar.newTab().setText("Display"), DisplayFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Y="), YFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Graph"), GraphFragment.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Table"), TableFragment.class, null);
if (findViewById(R.id.frame_layout) != null)
{
if (savedInstanceState != null)
{
return;
}
getSupportFragmentManager().beginTransaction().add(R.id.frame_layout, new ButtonFragment()).commit();
Log.i("MainActivity", "add.ButtonFragment");
}
}
I can see the tabs and nothing else within the ViewPager. My Frame Layout works perfectly fine though. How would I get ViewPager to work with this?

Why you do
mViewPager = new ViewPager(this);
mViewPager.setId(R.id.FrameLayout1); ?
The ViewPager is already on your layout.
Shoud do something like
mViewPager = (ViewPager)findViewById(R.id.FrameLayout1);
From the sample code they are creating the controls on runtime, while you have them in the xml.

Related

How to Increase Tab Text Size in TabLayout?

I have PodCastTab....i want fully Display TabName???
am not Asking about TabHost??
TabHost and TabLayout are Different...
This is ScreenShot of Tabs
once see this my code :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing the tablayout
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
//Adding the tabs using addTab() method
tabLayout.addTab(tabLayout.newTab().setText("Home").setIcon(R.drawable.home_selector));
tabLayout.addTab(tabLayout.newTab().setText("News").setIcon(R.drawable.news_selector));
tabLayout.addTab(tabLayout.newTab().setText("Videos").setIcon(R.drawable.video_selector));
tabLayout.addTab(tabLayout.newTab().setText("PodCasts").setIcon(R.drawable.podcast_selector));
tabLayout.addTab(tabLayout.newTab().setText("More").setIcon(R.drawable.more_selector));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
//tabLayout.setupWithViewPager(viewPager);
//Initializing viewPager
viewPager = (ViewPager) findViewById(R.id.pager);
//Creating our pager adapter
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
//Adding adapter to pager
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
#Override
public void onTabSelected(TabLayout.Tab tab) {
if (tab.getPosition() == 0) {
bottombar.show();
} else if (tab.getPosition() == 1) {
bottombar.hide();
} else if (tab.getPosition() == 2) {
bottombar.hide();
} else if (tab.getPosition() == 3) {
bottombar.hide();
}
super.onTabSelected(tab);
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
super.onTabUnselected(tab);
}
});
}
this is Xml File
<LinearLayout
android:id="#+id/main_layout"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.MainActivity">
<!-- our tablayout to display tabs -->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabBackground="#drawable/shape"
android:textAlignment="center"
app:tabTextColor="#838587"
app:tabSelectedTextColor="#fafafa"
app:tabIndicatorColor="#fffeff"
app:tabIndicatorHeight="2dp"
app:tabMode="fixed"
app:tabTextAppearance="#style/MyTabLayoutTextAppearance"
android:fitsSystemWindows="true"
app:tabMaxWidth="250dp"
android:minWidth="150sp"
app:tabGravity="fill">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"/>
how to display full Tab Text??
You can do this through TabLayout
First you inflate your tab if not present, using
RelativeLayout tab = (RelativeLayout) LayoutInflater
.from(MainActivity.this)
.inflate(R.layout.tab_layout, null, false);
and then you create a new tab and set a custom view using
tab_layout.newTab().setCustomView(tab);
Note that if you already have a tab (let's say you're working with a ViewPager), you can get the tab at a specific index instead of creating a new one by calling
tab_layout.getTabAt(0).setCustomView(tab);

Add Custom Grid View to the different tabs of a Sliding Tab Layout

I have made the different tabs of a Sliding Tab Layout by referring to this tutorial -
http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html
I want to add a Custom GridView to all the tabs of the Layout. I tried using an adapter but that does not work.
Kindly tell me a process or direct me to a tutorial.
swipe.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
<com.example.SlidingTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="#color/colorPrimary"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
Swipe.java
public class Swipe extends AppCompatActivity {
private ProgressBar progressBar;
private int progressStatus = 0;
ImageView img;
private Handler handler = new Handler();
Toolbar toolbar;
ViewPager pager;
ViewPageAdapter adapter;
SlidingTabLayout tabs;
CharSequence Titles[]={"M","N","A","G","W","D"};
int Numboftabs =6;
private static int pos;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.swipe);
Intent intent=getIntent();
pos=intent.getExtras().getInt("position");
img=(ImageView)findViewById(R.id.pac);
// Creating The Toolbar and setting it as the Toolbar for the activity
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs.
adapter = new ViewPageAdapter(getSupportFragmentManager(),Titles,Numboftabs);
// Assigning ViewPager View and setting the adapter
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
pager.setCurrentItem(pos);
// Assiging the Sliding Tab Layout View
tabs = (SlidingTabLayout) findViewById(R.id.tabs);
tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
// Setting Custom Color for the Scroll bar indicator of the Tab View
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
#Override
public int getIndicatorColor(int position) {
return getResources().getColor(R.color.tabsScrollColor);
}
});
// Setting the ViewPager For the SlidingTabsLayout
tabs.setViewPager(pager);
}
tab1.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="You Are In Tab 2"
android:id="#+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
There is a textview here. I don not want the text View but a Custom GridView.
tab1.java
public class tab1 extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View v =inflater.inflate(R.layout.tab1,container,false);
return v;
}
}
Similarly for all other tabs.

How to customize android tabs without changing the actionBar? (using ViewPager)

I'm not sure if that is possible. I'm trying to do a screen with tabs and lists in every tabs (I've done that already) and I've done a custom ActionBar for the title and some icons on it, now, i want to change the text color of the tabs, I've solved the background color but i can't find anything related to the text color, here is a piece of my code .java and my manifest.xml
addMenu();
// Set up the action bar.
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
actionBar.show();
actionBar.setDisplayOptions(actionBar.getDisplayOptions() | ActionBar.DISPLAY_SHOW_CUSTOM);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
#Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(
actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this)
);
}
the addMenu method (Only changes the Action Bar):
getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.order_title, null);
TextView textView = (TextView) view.findViewById(R.id.mytext);
textView.setWidth(getWindow().getWindowManager().getDefaultDisplay().getWidth());
textView.setPadding(0, 0, 50, 0);
textView.setGravity(Gravity.CENTER);
Typeface segoeui = Typeface.createFromAsset(getAssets(),"fonts/segoeui.ttf");
textView.setTypeface(segoeui);
textView.setText("Some Text");
getSupportActionBar().setCustomView(view);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.arrow_left);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#afafaf")));
and my Manifest.xml:
<activity
android:name=".Activity1"
android:label="#string/title_activity1"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="cleanpress.cleanpress.MainActivity" />
</activity>
This is how it looks:
http://i.stack.imgur.com/0hRbv.png
As you can see, the screen that i'm working is related to another one (if that's relevant).
I want to change just the text color of the Tabs (there are 3 tabs), anyone can help me please?
(I've already worked with HTML format and didn't work)
You should use android.support.design.widget.TabLayout to handle Tabs
so you can adjust:
app:tabIndicatorColor="#color/colorAccent" //indicator color
app:tabSelectedTextColor="#EEE" // text color on selected tab
app:tabTextColor="#EEE" // text color on tab
you should also use android.support.v7.widget.Toolbar for ActionBar.
Exmaple:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_alignParentTop="true"
android:text="#string/app_name"
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_below="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:tabIndicatorColor="#color/colorAccent"
app:tabSelectedTextColor="#EEE"
app:tabTextColor="#EEE" />
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tab_layout" />
</RelativeLayout>
In activity in onCreate
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
mAdapter = new YourPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mAdapter);
mTabLayout.setupWithViewPager(mPager);
Remember to add
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
in gradle dependencies
try this in styles
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarTabTextStyle">#style/Widget.MyTabText</item>
</style>
<style name="Widget.MyTabText" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/#your_color</item>
</style>

Android Navigation Drawer Appears on top of mRenderSurfaceView on API<=4.0.3

I am trying to combine Andengine's mRenderSurfaceView with a standard android application.
I created a standard Android project with navigation drawer, and succesfully plugged in the mRenderSurfaceView.
Problem: on Android 2.3 and on android 4.0.3, the navigation drawer appears below the mRenderSurfaceView only when it is being pulled out. When the drawer full opens it comes back to front.
Any idea how to make the drawer always on top, even when it is being pulled out?
XML Layout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.epollomes.caniconnect.MainActivity" >
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<fragment
android:id="#+id/navigation_drawer"
android:name="com.epollomes.caniconnect.NavigationDrawerFragment"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
OnCreate where the ,RenderSurfaceView is added to the FrameLayout
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ActivityUtils.requestFullscreen(this);
//
setContentView(R.layout.activity_main);
//
//
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.container);
FrameLayout.LayoutParams params = BaseGameActivity.createSurfaceViewLayoutParams();
// new FrameLayout.LayoutParams(
// LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
this.mRenderSurfaceView = new RenderSurfaceView(this);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
mRenderSurfaceView.setLayoutParams(params);
frameLayout.addView(mRenderSurfaceView);
frameLayout.setBackgroundColor(Color.BLACK);
// this.setContentView(this.mRenderSurfaceView,
// BaseGameActivity.createSurfaceViewLayoutParams());
//
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
mRenderSurfaceView.setPreserveEGLContextOnPause(true);
}
//
//
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(
R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
}
Please let me know if any additional info is needed.
Thanks

Android Fragment, No view found for id inside TabHost

I have a simple Android application with tabs set up using Tabhost and Fragments. On one of the tab pages, the fragment is a listview. What I want to do is when a user clicks on one of the items of the list view, open up a new view with more specific information based on the item clicked but preserving it so that the tabs are still there.
My approach is when a user clicks on a item in the listview, a new fragment is created and then from my main FragmentActivity class that owns all of these fragments and handles the tabbing logic, it will detach the currently shown fragment and add this "new" (singleStationListItem) fragment. The issue I am encountering is that I cannot add my new fragment to the fragmentTransaction with the R.id.realtabcontent and thus, it is not properly added. I get:
03-21 10:50:01.862: E/FragmentManager(1136): No view found for id 0x1010000 (android:attr/theme) for fragment singleStationListItem{40d090a0 #2 id=0x1010000}
where R.id.realtabcontent = 0x01010000;
I can attach it without the Id, but then users are not able to go back ( call addtobackstash() ). I have searched for this errors but other solutions do not relate to tabhost and I seem to do what is required, like call setContextView(...) in onCreate() to the xml file of the layout that includes the framelayout tag that I am trying to attach my fragment to. I can add my tab fragments to the R.id.realtabcontent without a problem. Does anyone know what could be causing my error and how I can fix it?
Note: I follow this tutorial for getting my tabs working. My code is very similar.
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
My Code:
activiy_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_body"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"
android:padding="5dp" />
<FrameLayout
android:id="#+android:id/realtabcontent" <--id that I want to set to
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-4dp"
android:layout_weight="0"
android:orientation="horizontal" />
</LinearLayout>
</TabHost>
</LinearLayout>
main_activity.java //parts from my fragment activity class
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Step 1: Inflate layout
setContentView(R.layout.activity_main);
// Step 2: Setup TabHost
initialiseTabHost(savedInstanceState);
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); //set the tab as per the saved state
}
}
public void onTabChanged(String tag) { //handles tab changes
TabInfo newTab = (TabInfo) this.mapTabInfo.get(tag);
if (mLastTab != newTab) {
FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction();
if (mLastTab != null) {
if (mLastTab.fragment != null) {
ft.detach(mLastTab.fragment);
}
}
if (newTab != null) {
if (newTab.fragment == null) {
newTab.fragment = Fragment.instantiate(this,
newTab.clss.getName(), newTab.args);
ft.add(R.id.realtabcontent, newTab.fragment, newTab.tag); //note it uses the R.id.realtabcontent without any issues here
} else {
ft.attach(newTab.fragment);
}
}
Log.d("fragment manager in activity: ", "" + ft.isEmpty());
mLastTab = newTab;
ft.commit();
this.getSupportFragmentManager().executePendingTransactions();
Log.d("ft ID: ", ft.toString());
}
}
//This is the callback function inside the listview fragment. I created an interface and it is overwritten in here as suggested by the Android SDK guide
public void onStationSelected(String station) {
FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction();
ft.addToBackStack(null);
ft.addToBackStack(null);
//create argument for new fragment that will be created
Bundle b = new Bundle();
b.putString("station", station);
Fragment displayStationInfo = Fragment.instantiate(this, singleStationListItem.class.getName(), b);
Fragment cur = getSupportFragmentManager().findFragmentById(R.id.realtabcontent);
ft.detach(cur);
ft.add(R.id.realtabcontent, displayStationInfo); <-- this line causes the error
ft.commit();
this.getSupportFragmentManager().executePendingTransactions();
}
singleStationListItem.java is here
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = this.getArguments();
getActivity().setContentView(R.layout.single_station_item_view);
TextView txtStation = (TextView) getActivity().findViewById(R.id.station_label);
String station = b.getString("station");
// displaying selected product name
Log.d(TAG, "passed in station information: " + station);
txtStation.setText(station);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = (LinearLayout)inflater.inflate(R.layout.single_station_item_view, container, false);
return v;
}
Any help would be greatly appreciated.
I realize this question was asked a while ago, I am posting an answer for others that may come across this question.
As far as I know, there is no Android id of 'realtabcontent'. In your XML, remove the 'android' part of your id for the FrameLayout.
<FrameLayout
android:id="#+id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
The complete XML code posted on the developer documentation is as follows:
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="#android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="#+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
Good luck and happy coding!

Categories

Resources