Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Tuesday, 19 October 2010

Android Text Strikethrough

I'm including a shopping list in my application. Do make an effective list I wanted to change the text of a selected item to be Strikethrough Easy to do in HTML and android handles HTML.. BUT this tag won't work in a dynamic strink.

So to format the text use

textview.setPaintFlags(textview.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

Sorted

Saturday, 16 October 2010

Switching Activies with OnClick

I've read through a lot of examples of how to switch through an activity but I have found that when you create your menu page activity the best practise is to implement the onlick listener directly.

This way you can easily and quickly code your buttons in one case statement




public class Example extends Activity implements OnClickListener

View btnExample = (ImageButton)findViewById(R.id.btnExample);
btnNewItem.setOnClickListener(this);

//On click for the buttons
@Override
public void onClick(View v) {

switch (v.getId()){
case R.id.btnExample:
startActivity(new Intent(this, MainList.class));
break;
//Add more if needed

SQLite, Create View Example

I've been having some issues with SQLite. I'm a confident SQL programmer and use it day to day. But some things are just different with SQLite and for some reason it's been taking me ages to find examples on such simple things such as views. I could find any good material for creating a view... correct me if there is something out there that I've missed.

Views are simple but need to be done in the correct place with the correct syntax.

This is a VERY basic view.. No INNER JOINS or anything. Ensure that the CREATE VIEW ect is in capitals otherwise it won't work! unlike the create table which does...




private static final String VIEW1 =
"CREATE VIEW inventoryview AS SELECT items.item, items.category, " +
"items.price, lists.listname, listitem.status, inventory.bbf, " +
"listitem.listid, listitem.itemid, listitem.quantity " +
"FROM items, lists, listitem, inventory " +
"WHERE " +
"listitem.itemid=items._id AND " +
"listitem.itemid=inventory.itemid AND " +
"listitem.listid=lists._id;";


@Override
public void onCreate(SQLiteDatabase db)
{ try{

db.execSQL(VIEW1);
}catch (Exception e)
{
Log.e("Create Error", e.toString());
e.printStackTrace();

}}


Easy Peasy