简体   繁体   中英

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

        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:

    <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. Thanks in advance!

This is written bad:

android:OnClick="calculate" />

should be:

android:onClick="calculate" />

R won't compile when you misspell something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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