Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello i have an android project.i have a mainactivity a listview i want to add data from class not from this mainactivity any help ?

What I have tried:

String[] x = new String[]{"AAA","BBB","CCC","DDD","EEE","FFF","GGG","HHH","III","JJJ","KKK","LLL","MMM","NNN","OOO","PPP","QQQ"};
ListView lv = (ListView) findViewById(R.id.listView1);
ArrayAdapter<string> test = new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1,x);
lv.setAdapter(test);
this is from mainactivity i want from class
Posted
Updated 14-Nov-16 8:12am
Comments
Richard MacCutchan 7-Nov-16 4:52am    
So create a class that does the work and then use an object of that class in your activity.

1 solution

mainactivity IS A class. Please elaborate on what you are trying to do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900