I'm developing a application that uses 4 tabs in a action bar. The app will send messages to a device via bluetooth. I selected the parts more importants of code here.
So, the third tab uses three seekbars for to configure a message that will be sent. The first seekbar control how many lines the message has. The second, seekbar control the time of exhibition and the last control how many messages will be sent.
In the fourth tab there are five buttons that are showed according the messages number selected in tab 3. When each button is selected, the corresponding lines of each message are showed according the number of lines selected in tab 3. Each line showed is a EditText.
When I write in the EdtitText in the tab 4 then change to tab 3, after, comeback to tab 4. The texts are there as i wrote, but when I change to tabr 2 or tab 1, then comeback to tab 4, the texts of messages 2, 3, 4 and 5 disappeared. Is necessary to emphasize that the text of message 1 continues intact.
I believe, that it is happening because I'm instantiating Linhas[i][j] with a new EditText inside my oncreateview, but I'm not sure. When I did try to instantiate it in my OnCreate and after I changed to tab 4, the app was close by a exception.
public class Trafeg extends FragmentActivity
implements ActionBar.TabListener{
static BluetoothAdapter Adaptador = BluetoothAdapter.getDefaultAdapter(); //Configura um adaptador
static BluetoothDevice Bt_Device=null;
static BluetoothSocket btssocket = null;
SectionsPagerAdapter mSectionsPagerAdapter;
public static Context context;
public static Context c;
public static EditText cx_txt_tx;
public static Button bt_alterar;
public static Button bt_enviar;
public static RadioButton Automatico;
public static RadioButton Economico;
public static RadioButton Maximo;
public static Button btnBT;
public static EditText etBT;
public static ProgressBar progresso;
public static TextView TV_Linhas;
public static TextView TV_Colunas;
public static TextView TV_Orient;
public byte[] buf= new byte[1];
public static boolean dado_1=true;
public static boolean flag_inicio=false;
public static boolean flag_fim=false;
public static boolean sucess=false;
public static boolean flag_orient=true;
public static boolean flag_conect=false;
public static boolean flag_dev1=true;
public static boolean repeat=false;
public static boolean conect_sucess=false;
public static OutputStream outStream = null;
public static InputStream inStream = null;
public static String RX_str="!";
public static String ns=null;
public static String serial_number=null;
public static String devAddress=null;
public static String Orient="H";
public static String linhas_str="1";
public static String colunas_str="1";
public static String brilho="E";
public static String estado= "Conectar";
public static String nome;
public static String teste_str=null;
static private final String tag = "BTS";
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); //UUID default HC-05
private static int N_Colunas=1;
private static int N_Linhas=1;
private static int qtLinhas = 4; // Quantidade de objetos EditText criados
private static int linhasEn = 1; // Quantidade de linhas habilitadas
private static int periodo = 1; // Período entre quadros
private static int qtQuadros = 5; // Quantidade total de quadros
public static int quadrosEn = 1; // Quantidade de quadros habilitados
private static int quadro = 0; // Quadro habilitado
private static EditText[][] Linhas = new EditText[qtQuadros+1][qtLinhas+1];
private static LinearLayout llLinhas[] = new LinearLayout[qtQuadros];
private static TextView tvQuadro;
public static Button btQuadro[] = new Button[5];
public static View rootView_configtext;
public static View rootView_edittext;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//Toast.makeText(this, "OnCreate", 0).show();
//Vincula as variáveis ao layout.
setContentView(R.layout.main_activity);
// inicializa action bar
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
c=this;
/*for(int i=1;i<qtQuadros;i++)
{
for(int j=0;j<qtLinhas;j++)
{
Linhas[i][j] = new EditText(c);
}
}*/
// Fixa orientação em retrato
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// Instancia o adaptador que irá retornar um fragmento para cada uma das 4
// páginas do aplicativo
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Inicializa a ViewPager
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
//Listener que verifica quando houve mudança de página
mViewPager
.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position)
{
//posiciona a action bar na Tab que foi selecionada
actionBar.setSelectedNavigationItem(position);
}
});
// Para cada uma das seções do aplicativo, adiciona uma tab na action bar
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++)
{
// Cria uma tab com o título correspondente ao titulo da pagina definido pelo adaptador
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
//Verifica se o bluetooth está desativado
if(!Adaptador.isEnabled())
{
Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBluetooth, 0); //Chama função que Pergunta ao usuário se ele quer
//ativar o bluetooth de seu telefone
}
mViewPager.setCurrentItem(1); //Posiciona a aplicação na Tab Main
}
public class SectionsPagerAdapter extends FragmentPagerAdapter
{
public SectionsPagerAdapter(FragmentManager fm)
{
super(fm);
}
@Override
public Fragment getItem(int position)
{
//Esse método é chamado para instanciar fragment com a página correspondente a position
Fragment fragment = new Fragment();
switch (position) {
case 0:
fragment = new configFragment();
break;
case 1:
fragment = new mainfragment();
break;
case 2:
fragment = new configtext();
break;
case 3:
fragment = new editfragment();
break;
default:
break;
}
Bundle args = new Bundle();
args.putInt(configFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
//retorna fragment
return fragment;
}
@Override
public int getCount() {
// Quantidade de telas
return 4;
}
@Override
public CharSequence getPageTitle(int position) {
//Retorna o título de cada tab
switch (position) {
case 0:
return "Config.\nControl.";
case 1:
return "Main";
case 2:
return "Config.\n Txt.";
case 3:
return "Edit.\nTxt";
}
return null;
}
}
//Tab1
public static class configFragment extends Fragment implements OnSeekBarChangeListener {
/**
* Cria a página de configuração da controladora
*/
public static final String ARG_SECTION_NUMBER = "section_number";
//private RadioGroup radioLinhas;
private View rootView;
public configFragment()
{
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.config_controladora_fragment, container, false);
bt_alterar = (Button)rootView.findViewById(R.id.alterar);
bt_enviar = (Button)rootView.findViewById(R.id.enviar);
Automatico=(RadioButton)rootView.findViewById(R.id.Auto);
Economico=(RadioButton)rootView.findViewById(R.id.Econ);
Maximo=(RadioButton)rootView.findViewById(R.id.Max);
SeekBar sbColunas = (SeekBar) rootView.findViewById(R.id.sb_Colunas);
SeekBar sbLinhas = (SeekBar) rootView.findViewById(R.id.sb_Linhas);
TV_Colunas= (TextView) rootView.findViewById(R.id.Ed_colunas);
TV_Linhas= (TextView) rootView.findViewById(R.id.Ed_linhas);
TV_Orient= (TextView) rootView.findViewById(R.id.Ed_Orient);
//Limita o progresso máximo das barras em 4 e inicializa-os em 1.
sbLinhas.setMax(4);
sbLinhas.setProgress(1);
sbColunas.setMax(4);
sbColunas.setProgress(1);
if(Orient.equals("H"))TV_Orient.setText("Orientação: Hori. ");
else if(Orient.equals("V")) TV_Orient.setText("Orientação: Vert. ");
TV_Linhas.setText("Nº de Linhas: "+linhas_str);
TV_Colunas.setText("Nº de Colunas: "+colunas_str);
return rootView;
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
}
//Tab 2
public static class mainfragment extends Fragment {
/**
* Cria a página do main
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public mainfragment()
{
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView_edittext = inflater.inflate(R.layout.main_fragment, container, false);
progresso = (ProgressBar) rootView_edittext.findViewById(R.id.progressBar1);
progresso.setVisibility(View.INVISIBLE);
etBT = (EditText) rootView_edittext.findViewById(R.id.bluetooth_et);
btnBT = (Button) rootView_edittext.findViewById(R.id.bt_button);
btnBT.setText(estado);
btnBT.setOnClickListener(new OnClickListener()//ViewViewView
{
@Override
public void onClick(View v)
{
conect_sucess=false;
repeat=false;
}
});
return rootView_edittext;
}
}
//Tab3
public static class configtext extends Fragment implements OnSeekBarChangeListener {
/**
* Cria a página de configuração de texto
*/
public static final String ARG_SECTION_NUMBER = "section_number";
//private RadioGroup radioLinhas;
private TextView tvQuadros, tvLinhas, tvPeriodo;
public configtext()
{
}
@Override
//Listener das seekbar
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
//se for a seekbar correspondente ao período
if(seekBar.getId() == R.id.sb_periodo)
{
//força o progresso em 1, no caso do progresso ser menor que 1
if(progress < 1) seekBar.setProgress(1);
//se o progresso não for menor que 1, o período recebe o progresso
else periodo = progress;
tvPeriodo.setText(Integer.toString(seekBar.getProgress()) + " s");
//Escreve o período selecionado no layout
}
//se for a seekbar correspondente ao número de quadros
else if(seekBar.getId() == R.id.sb_quadros)
{
//força o progresso em 1, no caso do progresso ser menor que 1
if(progress < 1)
{
seekBar.setProgress(1);
progress=1;
}
//se o progresso não for menor que 1, o múmero de quadros recebe o progresso
quadrosEn = progress;
//Escreve o número de quadros selecionado no layout
tvQuadros.setText(Integer.toString(seekBar.getProgress()));
if(btQuadro[0] != null)
{
//Verifica se o número de quadros não é nulo
for(int i=0; i<qtQuadros; i++)
{
//Log.d("Quadro (557)", Integer.toString(i));
//Torna visível a quantidade de quadros selecionados
if(i < quadrosEn) btQuadro[i].setVisibility(View.VISIBLE);
else btQuadro[i].setVisibility(View.INVISIBLE);
}
}
}
//se for a seekbar correspondente ao número de linhas
else if(seekBar.getId() == R.id.sb_linhas)
{
//força o progresso em 1, no caso do progresso ser menor que 1
if(progress < 1) seekBar.setProgress(1);
//se o progresso não for menor que 1, o múmero de linhas recebe o progresso
else linhasEn = progress;
//Escreve o número de linhas selecionado no layout
tvLinhas.setText(Integer.toString(seekBar.getProgress()));
//Chama a função que desenha as linhas
if(Linhas[0][0] != null) desenhaLinhas();
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
}
@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView_configtext = inflater.inflate(R.layout.config_text_fragmente, container, false);
tvPeriodo = (TextView) rootView_configtext.findViewById(R.id.TextView02);
tvQuadros = (TextView) rootView_configtext.findViewById(R.id.TextView03);
tvLinhas = (TextView) rootView_configtext.findViewById(R.id.TextView05);
SeekBar sbPeriodo = (SeekBar) rootView_configtext.findViewById(R.id.sb_periodo);
SeekBar sbQuadros = (SeekBar) rootView_configtext.findViewById(R.id.sb_quadros);
SeekBar sbLinhas = (SeekBar) rootView_configtext.findViewById(R.id.sb_linhas);
//Víncula variáveis a elementos do layout
sbPeriodo.setOnSeekBarChangeListener(this);
sbQuadros.setOnSeekBarChangeListener(this);
sbLinhas.setOnSeekBarChangeListener(this);
//Listener das seekbar
//Seta progresso default e progresso máximo para cada seekbar
sbPeriodo.setMax(5);
sbPeriodo.setProgress(periodo);
sbLinhas.setMax(4);
sbLinhas.setProgress(linhasEn);
sbQuadros.setMax(5);
sbQuadros.setProgress(quadrosEn);
return rootView_configtext;
//retorna a página criada
}
}
//tab4
public static class editfragment extends Fragment {
/**
* Cria apágina de edição de texto
*/
public static final String ARG_SECTION_NUMBER = "section_number";
private View rootView;
public editfragment()
{
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.edit_fragment, container, false);
//Víncula Variáveis a elementos do Layout
Linhas[0][0] = (EditText) rootView.findViewById(R.id.Linha01);
Linhas[0][1] = (EditText) rootView.findViewById(R.id.Linha02);
Linhas[0][2] = (EditText) rootView.findViewById(R.id.Linha03);
Linhas[0][3] = (EditText) rootView.findViewById(R.id.Linha04);
llLinhas[0] = (LinearLayout) rootView.findViewById(R.id.linearLayout1);
llLinhas[1] = (LinearLayout) rootView.findViewById(R.id.LinearLayout01);
llLinhas[2] = (LinearLayout) rootView.findViewById(R.id.LinearLayout02);
llLinhas[3] = (LinearLayout) rootView.findViewById(R.id.LinearLayout03);
llLinhas[4] = (LinearLayout) rootView.findViewById(R.id.LinearLayout04);
//inicializa um novo context
Context context = rootView.getContext();
tvQuadro = (TextView) rootView.findViewById(R.id.textView06);
tvQuadro.setText("Quadro " + Integer.toString(quadro+1));
//llLinhas[quadro].setVisibility(View.VISIBLE);
//Log.e("aaa",Integer.toString(quadro));
LayoutParams lpLinhas[] = new LayoutParams[4];
for(int i=0; i<qtLinhas; i++)
lpLinhas[i] = new LayoutParams(Linhas[0][i].getLayoutParams());
for(int i=0; i<qtLinhas; i++)
{
Linhas[0][i].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
Linhas[0][i].setImeOptions(EditorInfo.IME_ACTION_NEXT);
}
for(int i=1; i<qtQuadros; i++)
{
//Log.d("qtQuadros", Integer.toString(qtQuadros));
for(int j=0; j<qtLinhas; j++)
{
Linhas[i][j] = new EditText(c);
Linhas[i][j].setLayoutParams(lpLinhas[j]);
Linhas[i][j].setHint(Linhas[0][j].getHint());
Linhas[i][j].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
Linhas[i][j].setImeOptions(EditorInfo.IME_ACTION_NEXT);
//Linhas[i][j].setText(teste_str);
llLinhas[i].addView(Linhas[i][j]);
}
llLinhas[i].setLayoutParams(llLinhas[0].getLayoutParams());
llLinhas[i].setVisibility(View.INVISIBLE);
}
Button ButtonSend = (Button) rootView.findViewById(R.id.button_send);
Button ButtonClean = (Button) rootView.findViewById(R.id.button_clean);
btQuadro[0] = (Button) rootView.findViewById(R.id.bt_button);
btQuadro[1] = (Button) rootView.findViewById(R.id.button2);
btQuadro[2] = (Button) rootView.findViewById(R.id.button3);
btQuadro[3] = (Button) rootView.findViewById(R.id.button4);
btQuadro[4] = (Button) rootView.findViewById(R.id.button5);
btQuadro[quadro].setBackgroundColor(Color.argb(100, 36, 173, 89));
for(int i=1; i<qtQuadros; i++)
{
if(i<quadrosEn) btQuadro[i].setVisibility(View.VISIBLE);
else btQuadro[i].setVisibility(View.GONE);
}
desenhaLinhas();
llLinhas[quadro].setVisibility(View.VISIBLE);
OnClickListener ocl = new OnClickListener()
{
@Override
public void onClick(View v)
{
v.setBackgroundColor(Color.argb(100, 36, 173, 89));
llLinhas[quadro].setVisibility(View.INVISIBLE);
for(int i=0; i<qtQuadros; i++)
{
if(v.getId() == btQuadro[i].getId()) quadro = i;
else btQuadro[i].setBackgroundColor(Color.TRANSPARENT);
//Log.d("(763)","quadro=i");
}
tvQuadro.setText("Quadro " + Integer.toString(quadro+1));
desenhaLinhas();
llLinhas[quadro].setVisibility(View.VISIBLE);
}
};
for(int i=0; i<qtQuadros; i++) btQuadro[i].setOnClickListener(ocl);
ButtonClean.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
for(int i=0; i<qtQuadros; i++)
{
for(int j=0; j<qtLinhas; j++)
{
Linhas[i][j].setText("");
}
}
}
});
ButtonSend.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
String buffer = "{";
for(int i=0; i<quadrosEn; i++)
{
for(int j=0; j<linhasEn; j++)
{
if(j != 0) buffer += "\n";
if(Linhas[i][j].getText().length() != 0)
{
buffer += Linhas[i][j].getText().toString();
}
}
buffer += "\t";
buffer += Integer.toString(periodo);
}
buffer += "}";
}
});
return rootView;
}
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
mViewPager.setCurrentItem(tab.getPosition());
// TODO Auto-generated method stub
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
/*for(int i=1;i<qtQuadros;i++)
{
for(int j=0;j<qtLinhas;j++)
{
teste_str=Linhas[i][j].getText().toString();
//else teste_str= (Linhas[i][j].getText().toString())+"aaaa";
//teste_str="testando";
}
}*/
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public static void desenhaLinhas()
{
for(int i=0; i<qtLinhas; i++)
{
if(i < linhasEn) Linhas[quadro][i].setVisibility(View.VISIBLE);
else Linhas[quadro][i].setVisibility(View.INVISIBLE);
//Log.d("linhasEn",Integer.toString(linhasEn));
}
}
}
The XML corresponding of tab 4 is here. The other XMLNs is not here because characters limit.
Tab 4
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android1:gravity="center"
tools:context=".G4Bluetooth" >
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/linearLayout1"
android:layout_marginBottom="10dp"
android:text="Enviar" />
<Button
android:id="@+id/button_clean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button_send"
android:layout_alignBottom="@+id/button_send"
android:layout_alignLeft="@+id/linearLayout1"
android:text="Limpar" />
<LinearLayout
android1:id="@+id/linearLayout2"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_above="@+id/button_send"
android1:layout_alignLeft="@+id/button_clean"
android1:layout_alignRight="@+id/button_send"
android1:layout_marginBottom="10dp"
android1:orientation="horizontal" >
<Button
android1:id="@+id/bt_button"
style="?android:attr/buttonStyleSmall"
android1:layout_width="wrap_content"
android1:layout_height="match_parent"
android1:background="@android:color/transparent"
android1:text="1" />
<Button
android1:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android1:layout_width="wrap_content"
android1:layout_height="match_parent"
android1:background="@android:color/transparent"
android1:text="2" />
<Button
android1:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android1:layout_width="wrap_content"
android1:layout_height="match_parent"
android1:background="@android:color/transparent"
android1:text="3" />
<Button
android1:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android1:layout_width="wrap_content"
android1:layout_height="match_parent"
android1:background="@android:color/transparent"
android1:text="4" />
<Button
android1:id="@+id/button5"
style="?android:attr/buttonStyleSmall"
android1:layout_width="wrap_content"
android1:layout_height="match_parent"
android1:background="@android:color/transparent"
android1:text="5" />
</LinearLayout>
<LinearLayout
android1:id="@+id/linearLayout1"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignParentLeft="true"
android1:layout_alignParentRight="true"
android1:layout_alignParentTop="true"
android1:layout_margin="10dp"
android1:layout_marginLeft="10dp"
android1:layout_marginTop="10dp"
android1:orientation="vertical" >
<EditText
android1:id="@+id/Linha01"
android1:layout_width="fill_parent"
android1:layout_height="wrap_content"
android1:ems="10"
android1:hint="Linha 1"
android1:maxLength="64"
android1:minLines="1"
android1:visibility="invisible" />
<EditText
android1:id="@+id/Linha02"
android1:layout_width="fill_parent"
android1:layout_height="wrap_content"
android1:hint="Linha 2"
android1:maxLength="64"
android1:minLines="1"
android1:visibility="invisible" />
<EditText
android1:id="@+id/Linha03"
android1:layout_width="fill_parent"
android1:layout_height="wrap_content"
android1:hint="Linha 3"
android1:maxLength="64"
android1:minLines="1"
android1:visibility="invisible" />
<EditText
android1:id="@+id/Linha04"
android1:layout_width="fill_parent"
android1:layout_height="wrap_content"
android1:hint="Linha 4"
android1:maxLength="64"
android1:minLines="1"
android1:visibility="invisible" />
</LinearLayout>
<LinearLayout
android1:id="@+id/LinearLayout01"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignParentTop="true"
android1:layout_centerHorizontal="true"
android1:orientation="vertical" >
</LinearLayout>
<LinearLayout
android1:id="@+id/LinearLayout02"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignParentTop="true"
android1:layout_centerHorizontal="true"
android1:orientation="vertical" >
</LinearLayout>
<LinearLayout
android1:id="@+id/LinearLayout03"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignParentTop="true"
android1:layout_centerHorizontal="true"
android1:orientation="vertical" >
</LinearLayout>
<LinearLayout
android1:id="@+id/LinearLayout04"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignParentTop="true"
android1:layout_centerHorizontal="true"
android1:orientation="vertical" >
</LinearLayout>
<TextView
android1:id="@+id/textView06"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:layout_alignBaseline="@+id/button_clean"
android1:layout_alignBottom="@+id/button_clean"
android1:layout_centerHorizontal="true"
android1:text="Quadro 1" />
</RelativeLayout>
ViewPager instantiate maximum 3 views or fragments. It's recycle the container to put new view/fragment. For example when you are in your 2nd page only 1st and 3rd views/fragment are instantiate. A workaround is to keep an instance of your fragment on your adapter or use ViewPager.setOffscreenPageLimit(int) to increase maximum viewpager views/fragments instantiation