How to add ToolBar and ViewPager in the same Layout

0

When I add both components to the layout XML I get the following error in the ViewPager start line:

error: Error parsing XML: unbound prefix

Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/br.com.pixells.simuladorbr"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    <android.support.v7.widget.Toolbar
		xmlns:android="http://schemas.android.com/apk/res/android"
		android:id="@+id/toolbarListaJogos"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:background="#DC143C"
		app:subtitle="Teste"
		app:theme="@style/Theme.Abar.Widget"
		app:title="ToolBar" />
    
		<android.support.v4.view.ViewPager 
		    xmlns:android="http://schemas.android.com/apk/res/android"
			android:id="@+id/pager"  
			android:layout_width="match_parent"  
			android:layout_height="match_parent"  
			tools:context=".MainActivity" >  
		
		
		  
<!--  
This title strip will display the currently visible page title, as well as the page  
titles for adjacent pages.  
-->  
		  
			<android.support.v4.view.PagerTitleStrip  
				android:id="@+id/pager_title_strip"  
				android:layout_width="match_parent"  
				android:layout_height="wrap_content"  
				android:layout_gravity="top"  
				android:background="#33b5e5"  
				android:paddingBottom="4dp"  
				android:paddingTop="4dp" 
				android:textColor="#fff" />  
		
		  
		</android.support.v4.view.ViewPager> 

</LinearLayout>
    
asked by anonymous 04.12.2014 / 21:26

1 answer

1

Just add the reference to the namespace tools schema at the beginning of your xml. Just like the other schemas:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/br.com.pixells.simuladorbr"
    <!-- Adicione a linha abaixo -->
    xmlns:tools="http://schemas.android.com/tools

This inclusion is required for aapt to correctly interpret the namespace tags tools .

    
05.12.2014 / 03:02