It can be used for reference:
<? Xml version = "1.0" encoding = "UTF-8"?> <Br/> <ScrollView xmlns: android = "http://schemas.android.com/apk/res/android" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "fill_parent" <br/> android: windowSoftInputMode = "adjustUnspecified | stateHidden" <br/> <LinearLayout <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "fill_parent" <br/> android: orientation = "vertical" <br/> <ListView <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "380sp" <br/> android: id = "@ + id/CarAddlistView" <br/> android: paddingBottom = "2sp" <br/> </ListView> <br/> </LinearLayout> <br/> </ScrollView>
Java code:
Import java. text. dateFormat; <br/> import java. text. simpleDateFormat; <br/> import java. util. arrayList; <br/> import java. util. calendar; <br/> import java. util. date; <br/> import java. util. hashMap; <br/> import java. util. list; <br/> import java. util. map; <br/> import android. app. activity; <br/> import android. app. alertDialog; <br/> import android. app. datePickerDialog; <br/> import android. app. dialog; <br/> imp Ort android. app. progressDialog; <br/> import android. content. context; <br/> import android. content. dialogInterface; <br/> import android. content. intent; <br/> import android. OS. bundle; <br/> import android. view. layoutInflater; <br/> import android. view. view; <br/> import android. view. viewGroup; <br/> import android. view. windowManager; <br/> import android. view. view. onClickListener; <br/> import android. widg Et. adapterView; <br/> import android. widget. baseAdapter; <br/> import android. widget. datePicker; <br/> import android. widget. imageButton; <br/> import android. widget. linearLayout; <br/> import android. widget. listView; <br/> import android. widget. textView; <br/> import android. widget. toast; <br/> public class multiListview extends Activity {</p> <p> private ListView; <br/> private List <Map <String, Obj Ect> DataList; <br/> MyAdapter adapter; <br/> private Runnable viewOrders; </p> <p> private int mYear; <br/> private int mMonth; <br/> private int mDay; </p> <p> @ Override <br/> public void onCreate (Bundle savedInstanceState) {<br/> super. onCreate (savedInstanceState); <br/> // disable sleep <br/> getWindow (). setFlags (WindowManager. layoutParams. FLAG_KEEP_SCREEN_ON, <br/> WindowManager. layoutParams. FLAG_KEEP_SCREEN _ ON); <br/> setContentView (R. layout. listview); </p> <p> listview = (ListView) findViewById (R. id. listView); <br/> listview. setAdapter (adapter); <br/> listview. setOnItemClickListener (new ListView. onItemClickListener () {<br/> @ Override <br/> public void onItemClick (AdapterView <?> Parent, View view, int position, <br/> long arg3) {<br/> setSelectedValues (position); <br/>}< br/> }); <br/>}</p> <p> // select a listview event to process related logic <br/> private void setSelectedValues (int position) <br/>{< br/> Intent _ Intent; <br/> Bundle bundle; <br/> AreaOption area; <br/> switch (position) <br/> {<br/> case 0: // <br/> Toast. makeText (multiListview. this, "Please select your date 1 correctly! ", <Br/> Toast. LENGTH_SHORT ). show (); <br/> showDialog (date‑dialog_id); <br/> break; <br/> case 1: // <br/> Toast. makeText (multiListview. this, "Please select your date 2 correctly! ", <Br/> Toast. LENGTH_SHORT ). show (); <br/> showDialog (DATE2_DIALOG_ID); <br/> break; <br/>}< br/> @ Override <br/> protected Dialog onCreateDialog (int id) {<br/> switch (id) {<br/> case DATE1_DIALOG_ID: <br/> return new DatePickerDialog (this, <br/> mDateSetListener, <br/> mYear, mMonth, mDay ); <br/> case DATE2_DIALOG_ID: <br/> return new DatePickerDialog (this, <br/> mDateSetListener1, <br/> mYear, mMonth, mDay ); <br/>}< br/> return null; <br/>}< br/> private DatePickerDialog. onDateSetListener mDateSetListener = <br/> new datepickerdiener. onDateSetListener () {<br/> public void onDateSet (DatePicker view, int year, <br/> int monthOfYear, int dayOfMonth) {<br/> mYear = year; <br/> mMonth = monthOfYear; <br/> mDay = dayOfMonth; </p> <p> Map <String, Object> map = new HashMap <String, object> (); <br/> map. put ("left1", "date 1:"); <br/> map. put ("center1", getDate (); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); </p> <p> DataList. set (0, map); <br/> adapter. notifyDataSetChanged (); <br/>}< br/>}; </p> <p> private DatePickerDialog. onDateSetListener mDateSetListener1 = <br/> new DatePickerDialog. onDateSetListener () {<br/> public void onDateSet (DatePicker view, int year, <br/> int monthOfYear, int dayOfMonth) {<br/> mYear = year; <br/> mMonth = monthOfYear; <br/> mDay = dayOfMonth; </p> <p> Map <String, Object> map = new HashMap <String, object> (); <br/> map. put ("left1", "date 2:"); <br/> map. put ("center1", getDate (); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); </p> <p> DataList. set (1, map); <br/> adapter. notifyDataSetChanged (); <br/>}< br/>}; </p> <p> private List <Map <String, Object> getData () {<br/> List <Map <String, Object> list = new ArrayList <Map <String, Object> (); <br/> // 0 <br/> Map <String, Object> map = new HashMap <String, Object> (); <br/> map. put ("left1", "date 1:"); <br/> map. put ("center1", getDate (); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); <br/> list. add (map); <br/> // 1 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "date 2:"); <br/> map. put ("center1", getDate (); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); <br/> list. add (map); <br/> // 2 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "location 1:"); <br/> map. put ("center1", "select"); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); <br/> list. add (map); <br/> // 3 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "Location 2:"); <br/> map. put ("center1", "select"); <br/> map. put ("star1", "*"); <br/> map. put ("arrow1", ">"); <br/> list. add (map); <br/> // 4 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "Weight:"); <br/> map. put ("center1", "select"); <br/> map. put ("star1", ""); <br/> map. put ("arrow1", ">"); <br/> list. add (map); <br/> // 5 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "job:"); <br/> map. put ("center1", "select"); <br/> map. put ("star1", "*"); </p> <p> map. put ("left2", "Mobile Phone 1:"); <br/> map. put ("center2", "select"); <br/> map. put ("star2", "*"); <br/> map. put ("arrow2", ">"); </p> <p> map. put ("left3", "Mobile Phone 2:"); <br/> map. put ("center3", "select"); <br/> map. put ("star3", ""); <br/> list. add (map); <br/> // 6 <br/> map = new HashMap <String, Object> (); <br/> map. put ("left1", "Other:"); <br/> map. put ("center1", "select"); <br/> map. put ("arrow1", ">"); <br/> list. add (map); </p> <p> return list; <br/>}</p> <p> // obtain the date <br/> private String getDate () <br/>{< br/> StringBuilder Date = new StringBuilder () <br/>. append (mYear ). append ("-") <br/>. append (mMonth + 1 ). append ("-") <br/>. append (mDay ). append (""); </p> <p> return Date. toString (); <br/>}</p> <p> public final class ViewHolder {<br/> public TextView left1; <br/> public TextView left2; <br/> public TextView left3; <br/> public TextView center1; <br/> public TextView center2; <br/> public TextView center3; <br/> public TextView star1; <br/> public TextView star2; <br/> public TextView star3; <br/> public TextView arrow1; <br/> public TextView arrow2; <br/> public TextView arrow3; <br/> public LinearLayout line1; <br/> public LinearLayout line2; <br/> public LinearLayout line3; <br/>}</p> <p> public class MyAdapter extends BaseAdapter {<br/> private LayoutInflater mInflater; </p> <p> public MyAdapter (Context context) {<br/> this. mInflater = LayoutInflater. from (context); <br/>}< br/> @ Override <br/> public int getCount () {<br/> // TODO Auto-generated method stub <br/> return DataList. size (); <br/>}< br/> @ Override <br/> public Object getItem (int arg0) {<br/> // TODO Auto-generated method stub <br/> return null; <br/>}< br/> @ Override <br/> public long getItemId (int arg0) {<br/> // TODO Auto-generated method stub <br/> return 0; <br/>}< br/> @ Override <br/> public View getView (int position, View convertView, ViewGroup parent) {</p> <p> ViewHolder holder = null; <br/> if (convertView = null) {</p> <p> holder = new ViewHolder (); </p> <p> convertView = mInflater. inflate (R. layout. sourceaddlistview, null); <br/> holder. left1 = (TextView) convertView. findViewById (R. id. left1); <br/> holder. left2 = (TextView) convertView. findViewById (R. id. left2); <br/> holder. left3 = (TextView) convertView. findViewById (R. id. left3); <br/> holder. center1 = (TextView) convertView. findViewById (R. id. center1); <br/> holder. center2 = (TextView) convertView. findViewById (R. id. center2); <br/> holder. center3 = (TextView) convertView. findViewById (R. id. center3); <br/> holder. star1 = (TextView) convertView. findViewById (R. id. star1); <br/> holder. star2 = (TextView) convertView. findViewById (R. id. star2); <br/> holder. star3 = (TextView) convertView. findViewById (R. id. star3); <br/> holder. arrow1 = (TextView) convertView. findViewById (R. id. arrow1); <br/> holder. arrow2 = (TextView) convertView. findViewById (R. id. arrow2); <br/> holder. arrow3 = (TextView) convertView. findViewById (R. id. arrow3); <br/> holder. line1 = (LinearLayout) convertView. findViewById (R. id. line1); <br/> holder. line2 = (LinearLayout) convertView. findViewById (R. id. line2); <br/> holder. line3 = (LinearLayout) convertView. findViewById (R. id. line3); <br/> convertView. setTag (holder); </p> <p >}else {</p> <p> holder = (ViewHolder) convertView. getTag (); <br/>}</p> <p> holder. line2.setVisibility (convertView. GONE); <br/> holder. line3.setVisibility (convertView. GONE); </p> <p> holder. left1.setText (String) DataList. get (position ). get ("left1"); <br/> holder. center1.setText (String) DataList. get (position ). get ("center1"); <br/> holder. star1.setText (String) DataList. get (position ). get ("star1"); <br/> holder. arrow1.setText (String) DataList. get (position ). get ("arrow1"); </p> <p> if (position = 5) <br/>{< br/> holder. left2.setText (String) DataList. get (position ). get ("left2"); <br/> holder. center2.setText (String) DataList. get (position ). get ("center2"); <br/> holder. star2.setText (String) DataList. get (position ). get ("star2"); <br/> holder. arrow2.setText (String) DataList. get (position ). get ("arrow2"); </p> <p> holder. left3.setText (String) DataList. get (position ). get ("left3"); <br/> holder. center3.setText (String) DataList. get (position ). get ("center3"); <br/> holder. star3.setText (String) DataList. get (position ). get ("star3"); <br/> holder. arrow3.setText (String) DataList. get (position ). get ("arrow3"); </p> <p> holder. line2.setVisibility (convertView. VISIBLE); <br/> holder. line3.setVisibility (convertView. VISIBLE); <br/>}< br/> return convertView; <br/>}< br/>