That's my activity_main.xml, when I try see my Graphical it's returned any errors:
Exception raised during rendering: String index out of range: 0 Exception details are logged in Window > Show View > Error Log The following classes could not be found: - EditText (Change to android.widget.EditText, Fix Build Path, Edit XML)
I guess have something with error "activity_main.xml: String index out of range: 0" any like that menssage in my View.
Have anybody can I help me?
Down is my activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/lblPeso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/peso_" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lblPeso"
android:ems="10" android:inputType="none">
<requestFocus />
</EditText>
<TextView
android:id="@+id/lblAltura"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="21dp"
android:text="@string/altura_" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/lblAltura"
android:layout_below="@+id/lblAltura"
android:ems="10" android:inputType="none"/>
<Button
android:id="@+id/buttonCalcular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_marginTop="14dp"
android:layout_toRightOf="@+id/editText2"
android:text="@string/calcular_" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/buttonCalcular"
android:ems="10" android:inputType="none"/>
<EditText
android:id="@+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText3"
android:layout_below="@+id/editText3"
android:layout_marginTop="20dp"
android:ems="10" android:inputType=""/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/buttonCalcular"
android:layout_alignLeft="@+id/editText3"
android:text="@string/imc_" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText4"
android:layout_below="@+id/editText3"
android:text="@string/pesoIdeal_" />
(ANDROID)
Your xml is wrong, please correct all your left_below etc. declarations inside the xml. For example, You wrote:
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lblPeso"
android:ems="10" android:inputType="none">
but it has to be:
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/lblPeso" <---- Here is the issue
android:ems="10" android:inputType="none">
correct this in the complete layout everywhere you have done this. You wrote layout_below="@+id/...." but it hast to be layout_below="@id/..."
刚遇到同一问题,问题出在OP的editText4中为空的inputType(android:inputType =“”)。
在“”中不放任何内容,在编辑text4中将“不放”任何内容
<EditText android:id="@+id/editText4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editText3" android:layout_below="@+id/editText3" android:layout_marginTop="20dp" android:ems="10" android:inputType="none"/>
I have ever met this exception when I was working with a layout XML file in Android Studio. As this snapshot: Exception raised during rendering: String index out of range: 0
And I delete one of my code:
android:layout_gravity=""
After that the exception is gone.
So as for you, replace your code:
android:inputType=""
with
android:inputType="none"
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.