Hi,
I'm writing a application for Android which you can use when you are
on holiday with friends and you want to split the expenses during your
trip. You can add a new trip (using a sqlite DB for this). By editing
the trip you can add expenses and put which person paid for it.
However i'm having some trouble with the list of all trips that you
get when you want to edit one trip.
As you can see in the pictures, I can make the buttons without any
problem.
However when I make the text inside the button longer (this should be
<name of the trip and location>)
(for example: Name: Brussels - Location: Belgium)
When I do this some buttons go off-screen (so I can't see them) I
would like that they are drawn underneath eachother and not next to
each other.
Here is the code that I have to add them dynamically:
Also how can I add some styles to dynamically added buttons?
The first button that you see is a button that I declared in the XML-
file.
If you need more information about something please let me know
Thx in advance guys!
Kevin
I'm writing a application for Android which you can use when you are
on holiday with friends and you want to split the expenses during your
trip. You can add a new trip (using a sqlite DB for this). By editing
the trip you can add expenses and put which person paid for it.
However i'm having some trouble with the list of all trips that you
get when you want to edit one trip.
As you can see in the pictures, I can make the buttons without any
problem.
However when I make the text inside the button longer (this should be
<name of the trip and location>)
(for example: Name: Brussels - Location: Belgium)
When I do this some buttons go off-screen (so I can't see them) I
would like that they are drawn underneath eachother and not next to
each other.
Here is the code that I have to add them dynamically:
Code:
DBAdapter db = new DBAdapter(this);
//---get all trips---
db.open();
Cursor c = db.getAllTrips();
if (c.moveToFirst())
{
LinearLayout layout = (LinearLayout)
findViewById(R.id.layout);
do {
Button buttonView = new Button(this);
buttonView.setText(c.getString(1));
//buttonView.setText("Name: " + c.getString(1) + "-" +
"Location: " + c.getString(2));
layout.addView(buttonView);
} while (c.moveToNext());
}
db.close();
Also how can I add some styles to dynamically added buttons?
The first button that you see is a button that I declared in the XML-
file.
If you need more information about something please let me know
Thx in advance guys!
Kevin