views:

33

answers:

1

I have two ListViews, each of them containing a String[] that I created locally. I wanted to show both of them on the same screen, but still maintaining their properties (List 1 having its background color, while List 2 has its). Can this be accomplished?

Also, I'm trying to add a locally created TextView to the screen; I've tried addHeaderView() but it throws a Source not Found exception, with a BlockLayoutRequest set to false. I don't know what this means nor what's causing the error, can anyone point out what's wrong?

Here's my code:

Resources r = getResources();
String[] horarios_ida = r.getStringArray(R.array.horarios_b_1_dragao);
String[] aplicaveis_ida = HorariosAplicaveis(horarios_ida);
String[] horarios_volta = r.getStringArray(R.array.horarios_b_2_dragao);
String[] aplicaveis_volta = HorariosAplicaveis(horarios_volta);

ListView ida = new ListView(this);
ListView volta = new ListView(this);

TextView header = new TextView(this);
header.setText("DASS");
ida.addHeaderView(header); //throws error

        //displays the first array correctly, but I don't know what to do for the 2nd one
if(aplicaveis_ida.length>0)
{
    setListAdapter(new ArrayAdapter<String>(this, R.layout.b_dragao, aplicaveis_ida));
}
        ida = getListView();
        ida.setTextFilterEnabled(true);
setContentView(ida);
A: 

My Suggestion to you is, Create your List views, Text view in XML and load.

Add your contents to list view dynamically

Vinay