Note that there are some explanatory texts on larger screens.

plurals
  1. POListView in xml, setting Adapter to
    text
    copied!<p>I have following code: </p> <pre><code>public class ShowActivity extends ListActivity implements OnItemClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.show_list); ListView lv = getListView(); String[] projection = new String[]{ BaseColumns._ID, DepotTableMetaData.ITEM_NAME, DepotTableMetaData.ITEM_AMOUNT, DepotTableMetaData.ITEM_UNIT, DepotTableMetaData.ITEM_PPU, DepotTableMetaData.ITEM_TOTAL, DepotTableMetaData.ITEM_COMMENT}; Cursor c = managedQuery(ContentProviderMetaData.DepotTableMetaData.CONTENT_URI, projection, null, null, ContentProviderMetaData.DepotTableMetaData.DEFAULT_SORT_ORDER); String[] columns = new String[]{BaseColumns._ID,ContentProviderMetaData.DepotTableMetaData.ITEM_NAME, ContentProviderMetaData.DepotTableMetaData.ITEM_AMOUNT, ContentProviderMetaData.DepotTableMetaData.ITEM_UNIT, ContentProviderMetaData.DepotTableMetaData.ITEM_PPU, ContentProviderMetaData.DepotTableMetaData.ITEM_TOTAL, ContentProviderMetaData.DepotTableMetaData.ITEM_COMMENT}; int[] to = new int[]{R.id.lname,R.id.lamount,R.id.lunit,R.id.lppu,R.id.ltotal,R.id.lcomment}; Log.d("ShowActivity","Cursor, columns, to set - now setting adapter"); SimpleCursorAdapter simpleadapter = new SimpleCursorAdapter(this,R.layout.list_entry, c, columns, to); // ListView lv = (ListView)findViewById(R.id.ListView); this.setListAdapter(simpleadapter); lv.setOnItemClickListener(this); // intentCheck(); } </code></pre> <p>It works fine, but as you might have seen at my comments, i don't want to create the listview via getListView(), i want to do a usual setContentView(R.Layout.---) and populate a Listview, which is defined there. But all tutorials I have seen yet do it like that, and I have no clue how to change that to my wishes.</p> <p>How does my layout-xml have to look like? how do i "tell him to use it" ? Thanks in advance.</p>
 

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