如何打开多个XML形式从单一的主页 [英] how to open more than one xml forms from a single main page

查看:137
本文介绍了如何打开多个XML形式从单一的主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者到Android plz帮助我甲肝主页,我想打开每个按钮上一种形式....但它只是打开一个页面,其余页面给出错误.....
这里是主网页我的XML code

i am beginner to android plz help i hav a main page and i want to open one form on each button....but it is opening only one page the remaining pages gives error..... here is my xml code of main page

<?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>

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

and here coding of main page...............

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);


            }
        });





    }

}

推荐答案

声明所有你在标签内manifest文件调用为

Declare all the activity which you are calling in manifest file inside the tag as

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

如果您使用不同的包这些类,那么你必须用包以声明

or if you use these classes in different package then you have to declare with the package as

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

检查清单file..it可能对你有帮助...

check your manifest file..it may helpful to you...

这篇关于如何打开多个XML形式从单一的主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆