簡體   English   中英

無法解決或不是字段

[英]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"/>

因此,我添加了這些ID,但它們在維護性中無法識別。 提前致謝!

這寫得不好:

android:OnClick="calculate" />

應該:

android:onClick="calculate" />

拼寫錯誤時R不會編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM