Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display listview at bottom of form elements?
    primarykey
    data
    text
    <p>I want to show some form elements and below that i want to display a listview.</p> <p>I have used CursorAdapter approach for generating listview.</p> <p>My layout file is :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="Name:" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/&gt; &lt;EditText android:id="@+id/txtName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/name" android:ems="10" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"&gt; &lt;requestFocus /&gt; &lt;/EditText&gt; &lt;TextView android:id="@+id/startdate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/txtName" android:text="Start Date:" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/&gt; &lt;EditText android:id="@+id/txtStartDate" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/startdate" android:ems="10" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/categories" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="20sp" &gt; &lt;/TextView&gt; &lt;Button android:id="@+id/btnSave" style="?android:attr/buttonStyleSmall" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:text="Save" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And the code for generating list is:</p> <pre><code>DBAdapter db = new DBAdapter(Demo.this); db.open(); final Cursor c = db.getAllCategories(); CategoriesCursorAdapter categoriescursoradapter = new CategoriesCursorAdapter(Demo.this,c,CursorAdapter.NO_SELECTION); ListView lv = getListView(); lv.setAdapter(categoriescursoradapter); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int pos, long id) { c.moveToPosition(pos); int rowId = c.getInt(c.getColumnIndexOrThrow("_id")); Toast.makeText(getApplicationContext(), "rowid:"+rowId, Toast.LENGTH_LONG).show(); } }); db.close(); </code></pre> <p>CategoriesCursorAdapter code:</p> <pre><code>public class CategoriesCursorAdapter extends CursorAdapter { public CategoriesCursorAdapter(Context context, Cursor c, int flags) { super(context, c, flags); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); View retView = inflater.inflate(R.layout.activity_demo, parent, false); return retView; } @Override public void bindView(View view, Context context, Cursor cursor) { TextView textViewCategory = (TextView) view.findViewById(R.id.categories); textViewCategory.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(1)))); } } </code></pre> <p>When i run the application each form element is repeated for each list view.</p> <p><img src="https://i.stack.imgur.com/WDzbW.jpg" alt="Layout"></p> <p>Instead the form element should be generated once and the list view should be below that form elements and save buttom should be at bottom of the page.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload