Rotate View Hierarchy 90 degrees

I had the same problem and managed to solve it. Instead of rotating each view or the layout by hand, I used a LayoutAnimationController. First, place a file in /res/anim/ called rotation.xml <?xml version=”1.0″ encoding=”utf-8″?> <rotate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromDegrees=”0″ android:toDegrees=”-90″ android:pivotX=”50%” android:pivotY=”50%” android:duration=”0″ android:fillAfter=”true”> </rotate> Then, in your Activity’s onCreate, do @Override public void onCreate(Bundle icicle) … Read more

How to change default images of CheckBox

Drawable customdrawablecheckbox.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_checked=”false” android:drawable=”@drawable/unchecked_drawable” /> <item android:state_checked=”true” android:drawable=”@drawable/checked_drawable” /> <item android:drawable=”@drawable/unchecked_drawable” /> <!– default state –> </selector> yourcheckbox xml: <CheckBox android:id=”@+id/chk” android:button=”@drawable/customdrawablecheckbox” android:layout_alignParentLeft=”true” android:layout_width=”wrap_content” android:layout_height=”wrap_content” />

How can I make my layout scroll both horizontally and vertically?

I was able to find a simple way to achieve both scrolling behaviors. Here is the xml for it: <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:scrollbars=”vertical”> <HorizontalScrollView android:layout_width=”320px” android:layout_height=”fill_parent”> <TableLayout android:id=”@+id/linlay” android:layout_width=”320px” android:layout_height=”fill_parent” android:stretchColumns=”1″ android:background=”#000000″/> </HorizontalScrollView> </ScrollView>

Widgets don’t respond when re-added through code

We can invoke a dialog asking user to permit our app to be able to bind widget IDs with the following code: Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, sSavedWidgetId); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, mWidgetInfo.provider); startActivityForResult(intent, REQUEST_BIND_WIDGET); And bind widget IDs to make them actually work with: Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, maxWidth); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, … Read more

Android: Change Tab Text Color Programmatically

To change the text color of tabs, you need to get the view i.e TextView which is set as title of tabs and you can change it like this: TabHost tabhost = getTabHost(); for(int i=0;i<tabhost.getTabWidget().getChildCount();i++) { TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(…..); } hope this helps….

Dynamically creating Buttons and setting onClickListener

You could create a method that returns an onclickListener and takes a button as a parameter. And then use that method to set the onClicklistener in the first loop you have.. Update: code could be soemthing along these lines: View.OnClickListener getOnClickDoSomething(final Button button) { return new View.OnClickListener() { public void onClick(View v) { button.setText(“text now … Read more