我在編輯文本中設置雙精度時遇到了問題,無法擺脫該錯誤。我究竟做錯了什麼?嘗試將編號設置爲EditText中的文本
以下是我有:
final EditText somedouble_et = (EditText)findViewById(R.id.somedouble_search);
somedouble_et.setText(doubleNumber.toString(), TextView.BufferType.EDITABLE);
我得到的錯誤是不承認的TextView作爲一個階級。我的xml中是否有錯誤?
<EditText android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:id="@+id/somedouble"
android:inputType="numberSigned"
android:hint = ""
android:text = "@+id/somedouble_search"/>
這似乎並不重要什麼我使用的ID。
當我刪除此行時,仍然收到相同的錯誤:android:text =「@ + id/somedouble_search」 – Stagleton 2012-01-03 18:24:02
從錯誤消息中思考一下,你是否已經在代碼的頂部導入了TextView?還要確保findViewById正在尋找與您在Edit XML中設置xml相同的id。 – 2012-01-03 18:33:08
通常我習慣於「導入android.widget.TextView;」自動作爲選項,但直接寫入,基本上解決了我的問題。 – Stagleton 2012-01-03 18:49:07