Android Open Source - Adaptable-Adapter Demo Activity

From Project

Back to project page Adaptable-Adapter.


The source code is released under:

Apache License

If you think the Android project Adaptable-Adapter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 * Copyright 2013 Benjamin Lee//from   www .j av  a 2s.  c om
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.

package cm.ben.adapter.demo;

import android.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import cm.ben.adapter.Adapter;

public class DemoActivity extends ListActivity implements Adapter.AdapterListener {

  private Adapter<DemoItem> mAdapter;

  public void onCreate (Bundle savedInstanceState) {
    mAdapter = new Adapter<DemoItem>(this);
    mAdapter.add(new DemoItem("Basic Example", BasicActivity.class));
    mAdapter.add(new DemoItem("Endless Example", EndlessActivity.class));

  protected void onListItemClick (ListView listView, View view, int position, long id) {

  public View getView (int position, View convertView, ViewGroup parent) {
    if (convertView == null)
      convertView = LayoutInflater.from(this).inflate(R.layout.simple_list_item_1, parent, false);

    ((TextView) convertView.findViewById(;

    return convertView;

  private final class DemoItem {
    public final String name;
    public final Intent intent;

    public DemoItem (String name, Class clss) { = name;
      this.intent = new Intent(DemoActivity.this, clss);


Java Source Code List