0

我是android plz的初学者,请帮助我有一个主页,我想在每个按钮上打开一个表单......但它只打开一个页面,其余页面给出错误......这是我的主要xml代码页

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

    <SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="@drawable/stars"
        android:id="@+id/slidingDrawer1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:content="@+id/content"
        android:handle="@+id/handle" >
        <ImageView
            android:id="@+id/handle"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:src="@drawable/arrowup" />
        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="332dp"
            android:orientation="vertical" >
            <Button
                android:id="@+id/btnlenght"
                android:layout_width="192dp"
                android:layout_height="36dp"
                android:layout_marginLeft="66dp"
                android:layout_marginTop="22dp"
                android:background="#3366cc"
                android:textColor="#ffffff"
                android:text="@string/btnlenght" />

            <Button
                android:id="@+id/btnweight"
                android:layout_width="192dp"
                android:layout_height="36dp"
                android:layout_marginLeft="66dp"
                android:layout_marginTop="22dp"
                android:layout_weight="0.00"
                android:textColor="#ffffff"
                android:background="#3366cc"
                android:text="@string/btnweight" />


            <Button
                android:id="@+id/btnarea"
                android:layout_width="197dp"
                android:layout_height="36dp"
                android:layout_marginLeft="66dp"
                android:layout_marginTop="22dp"
                android:background="#3366cc"
                android:textColor="#ffffff"
                android:text="@string/btnarea" />

         <Button
         android:id="@+id/btntemperature"
         android:layout_width="197dp"
         android:layout_height="36dp"
         android:layout_marginLeft="66dp"
         android:layout_marginTop="22dp"
         android:textColor="#ffffff"
         android:background="#3366cc"
         android:text="@string/btntemperature" />
        <ImageView
        android:id="@+id/back"
        android:layout_width="74dp"
        android:layout_height="88dp"
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:layout_weight="0.24"
        android:src="@drawable/back" />


        </LinearLayout>

    </SlidingDrawer>

和这里的主页编码......

public class firstpage extends Activity {
/** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.firstpage);

     Button btnlenght=(Button)findViewById(R.id.btnlenght);
     Button btnweight=(Button)findViewById(R.id.btnweight);
     Button btnarea=(Button)findViewById(R.id.btnarea);
     Button btntemperature=(Button)findViewById(R.id.btntemperature);
     final ImageView handle=(ImageView)findViewById(R.id.handle);
     ImageView back=(ImageView)findViewById(R.id.back);
     SlidingDrawer slidingDrawer1=(SlidingDrawer)findViewById(R.id.slidingDrawer1);
     slidingDrawer1.setOnDrawerOpenListener(new OnDrawerOpenListener() {


        @Override
        public void onDrawerOpened() {
            // TODO Auto-generated method stub
            handle.setImageResource(R.drawable.downarrow1);

        }
    });
     slidingDrawer1.setOnDrawerCloseListener(new OnDrawerCloseListener() {

        @Override
        public void onDrawerClosed() {
            // TODO Auto-generated method stub
            handle.setImageResource(R.drawable.arrowup);
        }
    });
     btnlenght.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
        Intent n = new Intent(v.getContext(),lenght.class);
           startActivity(n);
       }


    });
     btnweight.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
            Intent a = new Intent(v.getContext(),weight.class);
               startActivity(a);
           }


        });
     btnarea.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
            Intent n = new Intent(v.getContext(),Area.class);
               startActivity(n);
           }

        });
     btntemperature.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
            Intent n = new Intent(v.getContext(),temperature.class);
               startActivity(n);
           }


        });
     back.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent n = new Intent(v.getContext(),A2ZunitconverterActivity.class);
                startActivity(n);
                finish();
                System.exit(0);


            }
        });





    }

}

4

1 回答 1

0

将您在标签内的清单文件中调用的所有活动声明为

<activity android:name=".temperature"/>
<activity android:name=".weight"/>

或者如果您在不同的包中使用这些类,那么您必须将包声明为

<activity android:name="com.org.xxx.temperature">
<activity android:name="com.org.xxx.weight">

检查您的清单文件..它可能对您有帮助...

于 2012-07-03T04:35:56.293 回答