LauncherActivity用法

public class IndexActivity extends LauncherActivity{
 

  //定义列表项的名称
 String names[] = {"单选按钮","复选框","自动补全","下拉框","列表","日期控件"};

 //定义列表项对应的实现类
 Class<?>[] clazzs =  {RadioActivity.class,CheckboxActivity.class,AutoCompleteActivity.class,SpinnerActivity.class,ExpandableListAcivity.class,DateActivity.class};
 
 @Override
 protected void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names);
            setListAdapter(adapter);
 }

 //根据列表项返回指定Activity对应的Intent
  @Override
  protected Intent intentForPosition(int position) {
          return new Intent(IndexActivity.this,clazzs[position]);
   }
}

你可能感兴趣的:(列表项指向intent)