Sunday, December 22, 2013

Android: How to use Listview in android


public class MainActivity extends Activity {
    String[] mData = {"A", "B", "C", "D"};
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
 
        ListView mListView = (ListView) findViewById(R.id.list);
        ArrayAdapter adapter 
              = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mData);
        mListView .setAdapter(adapter);
    }
}

No comments:

Post a Comment