取个名 2016-03-03 13:49 采纳率: 100%
浏览 2946
已采纳

AndroidApp点击登陆按钮停止运行

图片说明代码找不到哪错了,但还是停止运行了
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/znny02">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:orientation="vertical" >
<RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    <Button
        android:id="@+id/IP"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"

        android:background="@null"
        android:text="IP设置"
        android:textColor="#000080" />

    </RelativeLayout>
</LinearLayout>

<LinearLayout
     android:layout_width="match_parent"
     android:layout_height="0dp"
     android:layout_weight="1"
     android:orientation="vertical"
     android:background="#ffffff" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
       <TextView 
           android:id="@+id/name"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_centerVertical="true"
           android:textSize="25dp"
           android:layout_marginLeft="10dp"
           android:text="账户:"/> 
           <EditText 
               android:id="@+id/username"
               android:layout_toRightOf="@id/name"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_marginLeft="5dp"
               android:background="@null"
               android:layout_centerVertical="true"
               android:hint="请输入账户" />
    </RelativeLayout>
</LinearLayout>

<LinearLayout
     android:layout_width="match_parent"
     android:layout_height="0dp"
     android:layout_weight="1"
     android:orientation="vertical"
     android:background="#ffffff" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
       <TextView 
           android:id="@+id/password"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_centerVertical="true"
           android:textSize="25dp"
           android:layout_marginLeft="10dp"
           android:text="密码:"/> 
           <EditText 
               android:id="@+id/userpassword"
               android:layout_toRightOf="@id/password"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_marginLeft="5dp"
               android:background="@null"
               android:layout_centerVertical="true"
               android:inputType="textPassword"
               android:hint="请输入密码" />
    </RelativeLayout>
</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

    <CheckBox
        android:id="@+id/checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_centerVertical="true"
    android:text="记住密码"
    android:textColor="#000080" />

    <Button
        android:id="@+id/button2"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:text="注册" 
    android:background="@null"
    android:textColor="#000080" />

    <Button
       android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="5dp"
    android:layout_alignParentRight="true"
    android:background="@null"
    android:text="忘记密码"
    android:textColor="#000080" />
    </RelativeLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="60dp"
            android:text="返回"
            android:textColor="#000080" />
        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:layout_marginRight="60dp"
            android:onClick="click"
            android:text="登录"
            android:textColor="#000080" />

    </RelativeLayout>

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="vertical"
    android:layout_weight="1" >
</LinearLayout>

package com.gfxy.znny;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

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

// Log.i("MainActivity", "onCreate()");
}

public void click(View v) {
    Intent intent=new Intent(this,Activity01.class);
    startActivity(intent);
}

}

package com.gfxy.znny;

import android.app.Activity;
import android.os.Bundle;

public class Activity01 extends Activity {

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hjjc);

// Log.i("Activity01", "onCreate()");
}

}

<?xml version="1.0" encoding="utf-8"?>
package="com.gfxy.znny"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launche"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.gfxy.znny.MainActivity"
        android:label="@string/app_name" >
        </activity>
        <activity
            android:name="com.gfxy.znny.GUidt" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.gfxy.znny.Activity01"
        android:label="@string/app_name" >

    </activity>


</application>

  • 写回答

4条回答 默认 最新

  • u52983610 2016-03-06 15:12
    关注

    你把MainActivity里的click方法剪切到GUidt里面,因为xml之后从调用它的activity里寻找onclick方法,所以你之前那里会报错

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?