I have an application with tabs. In one tab I need to put data (strings) in rows. To do so I chose tableLayout but when I wanted to use a contextmenu on its rows it doesn’t work.
I can show the contextmenu onLongClick but the problem is that I can’t get the info about the selected row to edit or delete the selected row. Then I read in a discussion that using listView is better than tablelayout if we have many rows. But the examples I saw extend listactivity but I don’t want to do this.
So when I try working on a listView without extending listactivity I don’t know how to do it what I mean is that I’ve never used listView before so I try different examples I found on the internet to understand it but it’s not working. Here’s what I did so far for the listView:
String [] items=getRessources().getStringArray(R.arra.resolution);
//Resolution is an array of strings
ListView lv=(ListeView) findViewById(R.id.listView);
v.setAdapter(new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1, items);
When I compile it I get a list with elements of my array in it but first, I want to change the color of text which I can’t. And secondly I want to add rows dynamically to the list which I don’t know how to do either. I think I have to use an adapter to do it but I don’t know how.
Can someone please guide me through this. I just want to know how to attach my list to an adapter which’ll allow me to dynamically add rows, add contextMenu etc.
main Activity class:
Adapter class: