PUBLIC Class MainAICTIVITITITY Extends AppComPatactivity {
@Override
Protected void onCreate (Bundle Savedinstancestate) {
Super.Oncreate (Savedinstancestate);
setContentView (r.Layout.activity_main);
// 1 Find the control we care about
ListView lv = (listview) FindViewByid (R.id.LV);
// Set the data adapter
lv.setadapter (New MyAdapter ());
}
Private Class MyAdapter Extends Baseadapter {
@Override
public int getCount () {
Return 7;
}
@Override
Public Object GetITITEM (Int Position) {
Return null;
}
@Override
Public Long getItemid (int position) {
Return 0;
}
@Override
Public View GetView (Int Position, View ConvertView, ViewGroup Parent) {{
// 1 Find a way to convert the layout we defined into a view object
View view;
if (convertView == null) {
/*Create a new View object, you can convert a layout resource into a View object by a pitch
Resource is the layout file we define
1. Get the pitch service
view = view.inflate (getApplicationContext (), R.Layout.item, null);
2. Get the pitch service
View = layoutinflator.from (getApplicationContext ()). Inflate (R.Layout.item, Null);
*/
// 3. Get the airplane service
Layoutinflator inflationer = (layoutinflaater) getSystemService (layout_inflator_service);
View = Inflater.inflate (R.Layout.item, NULL);
} else {
// Reuse historical cache objects
view = convertView;
}
Return view;
}
}
}