Java 一次编辑6个整数文本问题?

Java 一次编辑6个整数文本问题?,java,android,eclipse,Java,Android,Eclipse,我创建了一个彩票程序,要求用户在一个EditText中输入6个数字,在另一个EditText中输入另一个“幸运数字”,如果这些数字符合一些条件,它们都将出现在同一个TextView中。 我的问题是,我不确定是否已将INT正确插入EditText,因为当我运行程序时,它会出现在模拟器中,但不会对我在EditText中编写的内容做出反应。有人能检查我的代码并告诉我我做错了什么吗 <EditText android:id="@+id/etNums" android:layout_

我创建了一个彩票程序,要求用户在一个EditText中输入6个数字,在另一个EditText中输入另一个“幸运数字”,如果这些数字符合一些条件,它们都将出现在同一个TextView中。 我的问题是,我不确定是否已将INT正确插入EditText,因为当我运行程序时,它会出现在模拟器中,但不会对我在EditText中编写的内容做出反应。有人能检查我的代码并告诉我我做错了什么吗

<EditText
    android:id="@+id/etNums"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/etLuckyNum"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<Button
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<TextView
    android:id="@+id/tvResult"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

</LinearLayout>
头等舱:

package com.example.hm195;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class MainActivity extends Activity {
class layout{
    public void layout(){
        Nums = (EditText)findViewById(R.id.etNums);
        Lnum = (EditText)findViewById(R.id.etLuckyNum);
        btn = (Button)findViewById(R.id.btn1);
        Result = (TextView)findViewById(R.id.tvResult);
    }
    EditText Nums, Lnum;
    Button btn;
    TextView Result;
}
class events {
    public void events(){
        l.btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                n.valid();

            }
        });
    }
}
nums n;
layout l;
events e;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    l = new layout();
    e = new events();
}

}
<EditText
    android:id="@+id/etNums"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/etLuckyNum"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<Button
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<TextView
    android:id="@+id/tvResult"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

</LinearLayout>
二等舱: 包com.example.hm195

import android.app.Activity;
import android.widget.Toast;

public class nums {
/*int a, int b, int c, int d, int e, int f, int g*/
MainActivity main;

 int a, b, c, d, e, f, g;
public void valid(){
     main.l.Nums.setText(a + "," + b + "," + c + "," + d + "," + e + "," + f);
     main.l.Lnum.setText(g);

    if ( a < 1 || a >37 || b < 1 || b >37 || c < 1 || c >37 || d < 1 || d >37 || e < 1 || e >37 || f < 1 || f >37) {
        Toast.makeText(main, "One or more of your six numbers is lower than 1 or higher than 37", 1).show();
        if (g < 1 || g > 7 ) {
        Toast.makeText(main, "Your lucky number is lower than 1 or higher than 7", 1).show();
        }
    }else {
        main.l.Result.setText(main.l.Nums.getText().toString() + " " + main.l.Lnum.getText().toString()); 
    }
}
}
<EditText
    android:id="@+id/etNums"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/etLuckyNum"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<Button
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<TextView
    android:id="@+id/tvResult"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

</LinearLayout>
导入android.app.Activity;
导入android.widget.Toast;
公共类NUM{
/*int a,int b,int c,int d,int e,int f,int g*/
主要活动主要;
INTA,b,c,d,e,f,g;
公共无效有效(){
main.l.Nums.setText(a+“,“+b+”,“+c+”,“+d+”,“+e+”,“+f”);
main.l.Lnum.setText(g);
如果(a<1 | a>37 | b<1 | b>37 | c<1 | c>37 | d<1 | d>37 | e<1 | e>37 | f<1 | f>37){
makeText(main,“六个数字中的一个或多个低于1或高于37”,1).show();
如果(g<1 | | g>7){
Toast.makeText(main,“您的幸运数字低于1或高于7”,1).show();
}
}否则{
main.l.Result.setText(main.l.Nums.getText().toString()+“”+main.l.Lnum.getText().toString());
}
}
}
xml:

<EditText
    android:id="@+id/etNums"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/etLuckyNum"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<Button
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<TextView
    android:id="@+id/tvResult"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

</LinearLayout>


是否出现某种错误?粘贴日志猫(如果是)如果要验证EditText的输入,需要使用
addTextChangedListener
并实现。日志猫中没有错误。如何(在哪里)使用addTextChangedListener?