android - Orders of objects in LinearLayout -


i have linearlayout works fine shown code below, change order of linear layouts.

<linearlayout 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:orientation="vertical"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     android:weightsum="100"     tools:context=".quicknotefragment" >      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         android:paddingbottom="5dp" >          <com.rithbo.noter.clearableedittext             android:id="@+id/pn_et_title"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:drawableright="@drawable/delete"             android:hint="@string/qn_et_title_hint"             android:inputtype="textcapsentences|textmultiline"             android:paddingtop="5dp" />     </linearlayout>      <com.rithbo.noter.clearableedittext         android:id="@+id/pn_et_body"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:drawableright="@drawable/delete"         android:hint="@string/qn_et_body_hint"         android:inputtype="textcapsentences|textmultiline" />      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         android:paddingbottom="5dp"         android:weightsum="100" >          <checkbox             android:id="@+id/pn_cb_ongoing"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="99"             android:text="@string/qn_cb_ongoing" />          <button             android:id="@+id/pn_b_create"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:text="@string/qn_b_create" />     </linearlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="center"         android:orientation="horizontal"         android:paddingbottom="5dp"         android:paddingtop="10dp" >          <button             android:id="@+id/pn_b_getpic"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="@string/pn_b_getpic" />          <button             android:id="@+id/pn_b_takepic"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="@string/pn_b_takepic" />     </linearlayout>  <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="center"         android:orientation="vertical"         android:paddingbottom="5dp"         android:paddingtop="10dp" >     <textview         android:id="@+id/pn_tv_preview"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:text="@string/pn_tv_preview" />      <imageview         android:id="@+id/pn_iv_preview"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:src="@drawable/gallery_icon" />      </linearlayout>  </linearlayout> 

but when move layout checkbox , button bottom, app force closes.

   <linearlayout 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:orientation="vertical"         android:paddingbottom="@dimen/activity_vertical_margin"         android:paddingleft="@dimen/activity_horizontal_margin"         android:paddingright="@dimen/activity_horizontal_margin"         android:paddingtop="@dimen/activity_vertical_margin"         android:weightsum="100"         tools:context=".frag1" >          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal"             android:paddingbottom="5dp" >              <com.xxx.xxx.clearableedittext                 android:id="@+id/pn_et_title"                 android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:drawableright="@drawable/delete"                 android:hint="@string/qn_et_title_hint"                 android:inputtype="textcapsentences|textmultiline"                 android:paddingtop="5dp" />         </linearlayout>          <com.xxx.xxx.clearableedittext             android:id="@+id/pn_et_body"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:drawableright="@drawable/delete"             android:hint="@string/qn_et_body_hint"             android:inputtype="textcapsentences|textmultiline" />                 <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:gravity="center"             android:orientation="horizontal"             android:paddingbottom="5dp"             android:paddingtop="10dp" >              <button                 android:id="@+id/pn_b_getpic"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="@string/pn_b_getpic" />              <button                 android:id="@+id/pn_b_takepic"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="@string/pn_b_takepic" />         </linearlayout>      <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:gravity="center"             android:orientation="vertical"             android:paddingbottom="5dp"             android:paddingtop="10dp" >         <textview             android:id="@+id/pn_tv_preview"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:text="@string/pn_tv_preview" />          <imageview             android:id="@+id/pn_iv_preview"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:src="@drawable/gallery_icon" />          </linearlayout>      <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal"             android:paddingbottom="5dp"             android:weightsum="100" >              <checkbox                 android:id="@+id/pn_cb_ongoing"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="99"                 android:text="@string/qn_cb_ongoing" />              <button                 android:id="@+id/pn_b_create"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:text="@string/qn_b_create" />         </linearlayout>      </linearlayout> 

i have no idea why?

here logcat:

07-17 16:32:08.886: e/androidruntime(19192): fatal exception: main 07-17 16:32:08.886: e/androidruntime(19192): java.lang.classcastexception: android.widget.textview cannot cast android.widget.button 07-17 16:32:08.886: e/androidruntime(19192):    @ com.rithbo.noter.picnotefragment.oncreateview(picnotefragment.java:75) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.fragment.performcreateview(fragment.java:1470) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:925) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1102) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1458) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:438) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.os.handler.handlecallback(handler.java:725) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.os.handler.dispatchmessage(handler.java:92) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.os.looper.loop(looper.java:137) 07-17 16:32:08.886: e/androidruntime(19192):    @ android.app.activitythread.main(activitythread.java:5222) 07-17 16:32:08.886: e/androidruntime(19192):    @ java.lang.reflect.method.invokenative(native method) 07-17 16:32:08.886: e/androidruntime(19192):    @ java.lang.reflect.method.invoke(method.java:511) 07-17 16:32:08.886: e/androidruntime(19192):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:795) 07-17 16:32:08.886: e/androidruntime(19192):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:562) 07-17 16:32:08.886: e/androidruntime(19192):    @ dalvik.system.nativestart.main(native method) 

here oncreateview() fragment:

@override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {         view rootview = inflater.inflate(r.layout.pic_note, container, false);          mimagebitmap = null;          b_create = (button) rootview.findviewbyid(r.id.pn_b_create);         b_gallery = (button) rootview.findviewbyid(r.id.pn_b_getpic);         b_camera = (button) rootview.findviewbyid(r.id.pn_b_takepic);         et_body = (edittext) rootview.findviewbyid(r.id.pn_et_body);         cb_ongoing = (checkbox) rootview.findviewbyid(r.id.pn_cb_ongoing);          et_title = (edittext) rootview.findviewbyid(r.id.pn_et_title);         et_title.requestfocus();          s_ticker_text = getstring(r.string.ticker_text);         s_subtext = getstring(r.string.sub_text);         s_toasttitletext = getstring(r.string.toast_missing_title);          b_create.setonclicklistener(this);         cb_ongoing.setonclicklistener(this);         b_gallery.setonclicklistener(this);         b_camera.setonclicklistener(this);          cb_ongoing.setchecked(false);         boolean_ongoing = false;          iv_preview = (imageview) rootview.findviewbyid(r.id.pn_iv_preview);         iv_preview.setimagebitmap(null);         iv_preview.setclickable(true);         iv_preview.setonclicklistener(this);           return rootview;     } 

thank you

edit: true fix... clean , rebuild , try launching app again

based on stack trace:

android.widget.textview cannot cast android.widget.button

at

com.rithbo.noter.picnotefragment.oncreateview(picnotefragment.java:75)

take @ picnotefragment class, line 75. or post code oncreateview() , can help.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -