简体   繁体   English

无法解决或不是字段

[英]Cannot be resolved or it's not a field

I am getting this error at lines " ** cannot be resolved or it's not a field". 我在“ **无法解决或不是字段”行中收到此错误。 mainactivity.java mainactivity.java

        Integer num1=Integer.parseInt(number1text.getText().toString()); 
        num2=Integer.parseInt(number2text.getText().toString()), 
        num3=Integer.parseInt(number3text.getText().toString());
        Integer del= num2*num2+4*num1*num3 ;
        Integer x1=-num2-del/2*num1 ;
        Integer x2=-num2+del/2*num1 ;
        TextView delta=(TextView)findViewById(R.id.deltatxt);
        TextView x1=(TextView)findViewById(R.id.x1txt);
        TextView x2=(TextView)findViewById(R.id.x2txt);
        delta.setText("Delta:"+del.toString());
        x1.setText("X1:"+x1.toString());
        x2.setText("X2:"+x2.toString());

fragment.xml: fragment.xml:

    <TextView
        android:id="@+id/num1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Numarul2(b)" />

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

    <TextView
        android:id="@+id/num2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Numarul3(c)" />

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

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/calc" 
        android:OnClick="calculate"/>

So I have added that ids but they are not recognised in maina-ctivity. 因此,我添加了这些ID,但它们在维护性中无法识别。 Thanks in advance! 提前致谢!

This is written bad: 这写得不好:

android:OnClick="calculate" />

should be: 应该:

android:onClick="calculate" />

R won't compile when you misspell something. 拼写错误时R不会编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM