Kinda new to Java programming, And I am trying to create a native app for android. my problem is, that when I select some stuff from my SQLite DB - I want to add a button with an eventlistener next to the output.
if(view==btnViewAll)
{
Cursor c=db.rawQuery("SELECT * FROM catalogue", null);
if(c.getCount()==0)
{
showMessage("Error", "No records found");
return;
}
StringBuffer buffer=new StringBuffer();
while(c.moveToNext())
{
buffer.append("Product name: "+c.getString(1)+"\n");
buffer.append("Description: "+c.getString(2)+"\n");
buffer.append("Price: "+c.getString(3)+"\n");
buffer.append("Image: "+c.getString(4)+"\n\n");
}
showMessage("All Products", buffer.toString());
}//end of btnViewAll
and then my ShowMessage is this -
public void showMessage(String title, String message) {
Builder builder = new Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}//end of Message!
This all pops up on my phone, with a list of the records in my DB - but I can't figure out, how to add a button for each row in there.
help is appreciated!