In android programming, screen or window object named Activity.
Here is example code that display list of items from simple strings array :
When you run the code you got something like this:
Here is example code that display list of items from simple strings array :
public class NisuiActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView lv= (ListView)findViewById(R.id.listview); // create the grid item mapping String[] from = new String[] {"rowid"}; int[] to = new int[] { R.id.item1 }; // prepare the list of all records List<hashmap<string, string>> fillMaps = new ArrayList<hashmap<string, string>>(); for(int i = 0; i < 10; i++){ HashMap<string, string> map = new HashMap<string, string>(); map.put("rowid", "" + i); fillMaps.add(map); } // fill in the grid_item layout SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to); lv.setAdapter(adapter); } }
When you run the code you got something like this:
No comments:
Post a Comment