Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ListView lv;
- private String[] data = {"one", "two", "three"}
- ..onCreate(){
- }
- ...
- lv = (ListView) findViewByID(R.id.lv);
- BaseAdapter a = new BaseAdapter(){
- @Override
- public int getCount(){}
- @Override
- public Object getItem(int position){
- return data[position];
- }
- @Override
- public long getItemId(int position){
- return 0;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent){
- if(convertView==null) convertView = new TextView(MainActivity.this);
- TextView tv = (TextView) convertView;
- tv.setText(data[position]);
- // I am going to create a new class only if have nothing to recycle
- // and I fill my views with the proper piece of elements
- return tv;
- }
- }
- lv.setAdapter(a);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement