Code example for ListView

Methods: setAdapter, setOnItemClickListener

    /** Called when the activity is first created. */ 
    public void onCreate(Bundle savedInstanceState) {
        mListView = new ListView(this);
        mListView.setAdapter(new BaseAdapter() {
            public View getView(int position, View convertView, ViewGroup parent) {
                if (convertView == null) {
                    LayoutInflater li = LayoutInflater.from(MainActivity.this);
                    convertView = li.inflate(android.R.layout.simple_list_item_1, parent, false);
                TextView tv = (TextView)convertView.findViewById(;
                Class<?> cls = TESTS[position];
                return convertView;
            public long getItemId(int position) {
                return position;
            public Object getItem(int position) {
                return TESTS[position];
            public int getCount() { 
                return TESTS.length;
        mListView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Class<?> cls = (Class<?>) view.getTag();
                Intent intent = new Intent(MainActivity.this, cls);
Connect your IDE to all the code out there  Get Codota for Java