2 shengry0716 shengry0716 于 2013.11.24 20:48 提问

JAVA写成后导出apk文件无法运行

初学JAVA,想做一个两个页面间跳转的APP,主页面输入用户名密码(为方便起见,先将其在程序中设定为1234,不等于1234则跳转第二个页面重新输入,等于执行其他,但因目前没有其他页面,故都转到重输入页面,程序不显示BUG,但apk文件运行不了,求各位帮忙。。。真的很急,以下是代码package com.example.health_monitor;

import com.example.health_monitor.R;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
private Button submit1;
private TextView instruction1;
private TextView username1;
private TextView password1;
private EditText user1;
private EditText pass1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
submit1=(Button)findViewById(R.id.button1);
instruction1=(TextView)findViewById(R.id.textView3);
username1=(TextView)findViewById(R.id.textView1);
user1=(EditText)findViewById(R.id.editText1);
String text1=user1.getText().toString();
final int textint1 = Integer.valueOf(text1).intValue();
password1=(TextView)findViewById(R.id.textView2);
pass1=(EditText)findViewById(R.id.editText2);
String text2=pass1.getText().toString();
final int textint2 = Integer.valueOf(text2).intValue();
submit1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(textint1==1234&&textint2==1234)
{Intent call_second_Interface=new Intent();
call_second_Interface.setClass(MainActivity.this,reenter.class);
startActivity(call_second_Interface);}
else {Intent call_second_Interface=new Intent();
call_second_Interface.setClass(MainActivity.this,reenter.class);
startActivity(call_second_Interface);}}
// TODO Auto-generated method stub

    });

    }


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}
以上是主页面代码
package com.example.health_monitor;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class reenter extends Activity {
private Button submit1;
private TextView instruction1;
private TextView username1;
private TextView password1;
private EditText user1;
private EditText pass1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bmeg_reenter);
submit1=(Button)findViewById(R.id.button1);
instruction1=(TextView)findViewById(R.id.textView3);
username1=(TextView)findViewById(R.id.textView1);
user1=(EditText)findViewById(R.id.editText1);
String text1=user1.getText().toString();
final int textint1 = Integer.valueOf(text1).intValue();
password1=(TextView)findViewById(R.id.textView2);
pass1=(EditText)findViewById(R.id.editText2);
String text2=pass1.getText().toString();
final int textint2 = Integer.valueOf(text2).intValue();
submit1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if(textint1==1234&&textint2==1234)
        {Intent call_second_Interface=new Intent();
        call_second_Interface.setClass(reenter.this,reenter.class);
        startActivity(call_second_Interface);}
            else {Intent call_second_Interface=new Intent();
            call_second_Interface.setClass(reenter.this,reenter.class);
            startActivity(call_second_Interface);}}
            // TODO Auto-generated method stub





    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}
以上是第二个重输入页面代码。。。第一次用JAVA,求不要嘲笑。。。

Csdn user default icon
上传中...
上传图片
插入图片