Tap the application close button

0

I followed this tutorial to create a layout with tabs .

After this, I created a button in XML, which is displayed without action, because it is only in XML.

I want to open another Activity from the touch of this button, but when I touch it, the application closes. Even though I have already declared the new Activity in Manifest , the problem persists.

Where is the error? How should this button be declared?

Here are the codes:

PrincipalActivity.java

public class PrincipalActivity extends FragmentActivity implements ActionBar.TabListener {

ActionBar barDimens;
ViewPager pagerDimens;
FragmentPageAdapter fpaDimens;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_principal);


    pagerDimens = (ViewPager) findViewById(R.id.pager_dimens);
    fpaDimens = new FragmentPageAdapter(getSupportFragmentManager());

    barDimens = getActionBar();
    pagerDimens.setAdapter(fpaDimens);
    barDimens.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    barDimens.addTab(barDimens.newTab().setText("VIGAS").setTabListener(this));
    barDimens.addTab(barDimens.newTab().setText("PILARES").setTabListener(this));

    pagerDimens.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            barDimens.setSelectedNavigationItem(arg0);

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {


        }

        @Override
        public void onPageScrollStateChanged(int arg0) {


        }
    });
} // fecha onCreate

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    pagerDimens.setCurrentItem(tab.getPosition());

}

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


}

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


}
}

activity_principal.xml

<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager_dimens"
android:layout_width="match_parent"
android:layout_height="match_parent" >

VigasFragment.java

public class VigasFragment extends Fragment implements OnClickListener {
Button btnBiapsb;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.vigas_fragment, container, false);

    btnBiapsb = (Button) rootView.findViewById(R.id.biapsb);
    btnBiapsb.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intBiapsb = new Intent(v.getContext(), VigMetBiapsb.class);
            startActivityForResult(intBiapsb, 0);
        }
    });
    return rootView;

}// fecha onCreateView

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
}

}

vigas_fragment.xml

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#F8F8F8" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="15dp"
    android:paddingRight="15dp"
    android:paddingBottom="15dp" >

    <TextView
        android:id="@+id/vigasmet"
        android:text="@string/vigasmetalicas"
        style="@style/subtitulos" />

    <Button
        android:id="@+id/biapsb"
        android:layout_below="@+id/vigasmet"
        android:text="@string/biapsb"
        android:drawableLeft="@drawable/vigabiap2"
        style="@style/botoesdimens" />

</RelativeLayout>

</ScrollView>
    
asked by anonymous 20.11.2014 / 23:14

0 answers