android - Using a CheckBox which doesn't exist in current layout -
in application have class named chatactivity. showing listview. in oncreate have set layout like
super.oncreate(savedinstancestate); setcontentview(r.layout.conversation_window);
conversation_window.xml looks this
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:divider="@null" android:padding="16dp" android:fitssystemwindows="true"> <listview android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@null" android:id="@+id/thread_listview" android:layout_below="@+id/edittext" android:layout_weight="1" /> <view android:id="@+id/innerline" android:layout_width="match_parent" android:layout_height="1dp" android:layout_margintop="5dp" android:background="#9e9e9e" android:layout_weight="0" android:layout_marginbottom="12dp"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="12sp" android:textstyle="bold" android:textcolor="#212121" android:layout_marginbottom="8dp" android:text="(1) 0/158" android:id="@+id/character_count_textview"/> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:layout_weight="0" android:layout_marginbottom="10dp"> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/compose_edittext" android:layout_weight="1" android:layout_marginright="5dp" android:hint="এখানে লিখুন..." android:inputtype="textmultiline|textcapsentences" android:scrollbars="vertical" android:background="@drawable/apptheme_textfield_disabled_holo_light" /> <imagebutton android:layout_width="50dp" android:layout_height="wrap_content" android:id="@+id/send_imagebutton" android:background="@mipmap/send_black" /> </linearlayout>
for each row of listview there xml called list_item_chat_message.xml looks this
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <checkbox android:id="@+id/checkbox_conversation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="8dp" android:layout_margintop="20dp" android:visibility="gone" /> <linearlayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_margin="10dp" android:orientation="vertical"> <linearlayout android:id="@+id/contentwithbackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:background="@drawable/in_message_bg" android:orientation="vertical"> <textview android:id="@+id/txtmessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxwidth="200dp" android:textcolor="@android:color/black" android:textsize="16sp" /> </linearlayout> <textview android:id="@+id/timeinfo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:padding="3dp" android:textcolor="@android:color/darker_gray" /> </linearlayout>
there checkbox in list_item_chat_message.xml want use in chatactivity class setoncheckedchangelistener.but when writing in chatactivity class
itemcheckbox = (checkbox) findviewbyid(r.id.checkbox_conversation);
it throws null object reference. how can declare checkbox in activity?
Comments
Post a Comment