Can anyone help me with this error? Occurs when executing a setarView method. Here is the code:
package ufc.es.com.br.doesempre.modelo;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import ufc.es.com.br.doesempre.R;
/**
* Created by 349059 on 16/06/16.
*/
public class Fragmento_Principal extends Fragment {
private ViewPager viewPager;
private ImageViewPagerAdapter imPadpter;
private ImageView bt1, bt2, bt3;
public Fragmento_Principal() {
}
@Override
public void onViewCreated(View v, Bundle bd) {
super.onViewCreated(v, bd);
setarView();
setarTab();
clicBotaoCirculado();
}
public View onCreatedView(LayoutInflater infl, ViewGroup cont, Bundle savedInstanceState) {
return infl.inflate(R.layout.fragmento_principal, cont, false);
}
private void clicBotaoCirculado() {
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bt1.setImageResource(R.drawable.circulo_cheio);
viewPager.setCurrentItem(0);
}
});
bt2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bt1.setImageResource(R.drawable.circulo_cheio);
viewPager.setCurrentItem(1);
}
});
bt3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bt1.setImageResource(R.drawable.circulo_cheio);
viewPager.setCurrentItem(2);
}
});
}
private void setarView() {
viewPager = (ViewPager) viewPager.findViewById(R.id.viewImageFragMain);
imPadpter = new ImageViewPagerAdapter(getActivity(),getFragmentManager());
viewPager.setAdapter(imPadpter);
viewPager.setCurrentItem(0);
iniciarBotao();
}
private void setarTab() {
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int posicao) {
}
public void onPageScrolled(int a, float b, int c) {
}
@Override
public void onPageSelected(int posicao) {
bt1.setImageResource(R.drawable.circulo);
bt2.setImageResource(R.drawable.circulo);
bt3.setImageResource(R.drawable.circulo);
acaoDoBotao();
}
});
}
private void acaoDoBotao(int acao) {
switch (acao) {
case 1:
bt1.setImageResource(R.drawable.circulo_cheio);
break;
case 2:
bt2.setImageResource(R.drawable.circulo_cheio);
break;
case 3:
bt3.setImageResource(R.drawable.circulo_cheio);
break;
}
}
private void iniciarBotao() {
bt1 = (ImageView) getView().findViewById(R.id.btn1);
bt1.setImageResource(R.drawable.circulo_cheio);
bt2 = (ImageView) getView().findViewById(R.id.btn2);
bt3 = (ImageView) getView().findViewById(R.id.btn3);
}
private void setarBotao(Button btn, String txt, int altura, int largura){
btn.setHeight(altura);
btn.setWidth(largura);
btn.setText(txt);
}
}
Returns the following error:
(in ImageViewPageAdapter can not be applied to (Activity android.app.FragmentManager)