Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid- Adding subrows to a ListView!
    text
    copied!<p>ive been attempting to add subrows to a listview. I have a taxi app which at present shows a list of taxi company names, i want to be able to add some sub rows in which show address, postcode etc. </p> <p>I have had some attempts at this but none have been successful. I am calling my strings from an array in the strings.xml file. My code at the moment is :</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String[] taxi = getResources().getStringArray(R.array.taxi_array); setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.listtaxi, taxi)); final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; a, View v, final int position, long id) { final int selectedPosition = position; AlertDialog.Builder adb=new AlertDialog.Builder(ListTaxi.this); adb.setTitle("Taxi Booking"); adb.setMessage("You Have Selected: "+lv.getItemAtPosition(position)); adb.setPositiveButton("Book", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(getApplicationContext(), Booking.class); intent.putExtra("booking", taxi[selectedPosition]); startActivity(intent); } }); adb.setNegativeButton("Cancel", null); adb.show(); } }); </code></pre> <p>If anyone can help me get round this problem it would be very much appreciated. </p> <p>The original question i asked is here: <a href="https://stackoverflow.com/questions/4587301/android-adding-subitem-to-a-listview">Android - Adding Subitem to a listview</a></p> <p>Thanks</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