Create a separate layout header.xml and add below code:
<TableLayout
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<EditText android:id="@+id/newmessagecontent"
android:layout_height="wrap_content"
android:singleLine="false"
android:gravity="top"
android:layout_width="250dp"
android:layout_alignParentTop="true"
/>
<Button android:layout_height="wrap_content"
android:id="@+id/sendmessage"
android:text="Send"
android:layout_width="wrap_content"
/>
</Table>
</TableLayout>
Update the main activity java code with below code
ListView lv = getListView(); LayoutInflater inflater = getLayoutInflater(); ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false); //header is above XML code lv.addHeaderView(header, null, false);
Next Article: Android - Providing UP Navigation
For any questions, suggestions and feedback, Please write to us. Thanks for Reading :)
No comments:
Post a Comment