Thursday, August 19, 2010

Miscellaneous Tips

How to stretch a control?

Set Layout_weight to greater than 0




Issue with Check box in a list view

When I use anything other than textview in a listview, the context menu stop working. Now to have a check box in a list view, I have to use CheckedTextView. But the text in CheckedTextView appears on the left side of the checkbox. I don’t know how to change it, so I use a CheckedTextView with no text and a TextView.


Show checkbox in CheckedTextView

<CheckedTextView android:id="@+id/categoryCheckedTextView"

Display simple MessageBox in Android

AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Packing List");
alertDialog.setMessage("Could not find the file.");;


Change emulator orientation

Use KEYPAD_7 or KEYPAD_9 on you desktop. You need to turn off your Num Lock.

Dynamically change the background color

To dynamically change the background color, use myView.setBackgroundResource(R.color.my_color) instead myView.setBackgroundColor(R.color.my_color)


How to align text in text view?

When trying to align the text to the right in text , set the “layout_gravity” to right doesn’t work. Need to set “gravity” to right.

No comments:

Post a Comment