Exemple #1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.main);

    ItemAdapter adapter;
    try {
      adapter = ItemAdapter.createFromXml(this, R.xml.events_items);
      setListAdapter(adapter);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setActionBarContentView(R.layout.list);

    ItemAdapter adapter = new ItemAdapter(this);
    adapter.add(new TextItem("Basic items"));
    adapter.add(new TextItem("XML items"));
    adapter.add(new TextItem("Tweaked item cell"));
    adapter.add(new TextItem("SegmentedBar"));
    adapter.add(new TextItem("ActionBarActivity"));

    mListView = (ListView) findViewById(android.R.id.list);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(mItemClickHandler);
  }