Android Layout change causes type-error -


i trying change working android app 1 column layout 2 column layout.

when this, execution error on mainactivity.java, in line here:

imageview picview = (imageview)findviewbyid(r.id.picture); 

the error states:

android.widget.textview cannot cast android.widget.imageview 

from understand findviewbyid(r.id.picture) returns textview. make sense me. defined imageview in activity_main.xlm:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"  android:baselinealigned="false">     <linearlayout      android:layout_width="0dp"     android:layout_weight="1"     android:layout_height="fill_parent"     android:orientation="vertical">         <button         android:id="@+id/capture_btn"         android:text="@string/capture"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         />         <button         android:id="@+id/pick_btn"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="@string/pick"         android:onclick="onclick" />         <textview             android:id="@+id/status"             android:layout_width="wrap_content"             android:layout_height="wrap_content"/>     </linearlayout>     <linearlayout      android:layout_width="0dp"     android:layout_weight="1"     android:layout_height="fill_parent"     android:orientation="vertical">         <imageview         android:id="@+id/picture"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:contentdescription="@string/picture"         android:layout_margin="5dp"         android:background="@drawable/pic_border" />     </linearlayout> </linearlayout> 

note: same app works find below (1 column) activity_main.xlm:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <button android:id="@+id/capture_btn" android:text="@string/capture" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <button android:id="@+id/pick_btn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/pick" android:onclick="onclick" /> <imageview android:id="@+id/picture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentdescription="@string/picture" android:layout_margin="5dp" android:background="@drawable/pic_border" />     <textview         android:id="@+id/status"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/> </linearlayout> 

clean project run again.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -