Posts

Showing posts from August, 2013

Android Trick - select Gridview item and make the cell highlighted

As Title said, I am making a customized calendar view . For date part I am using Gridview. But after I set item background and using setSelection(int) I could not highlighted the item I selected. this is the drawable for cell view background. <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:drawable="@drawable/bg_purple_round_corner" android:state_pressed="true">     <item android:drawable="@drawable/bg_purple_round_corner" android:state_checked="true">     <item android:drawable="@drawable/bg_purple_round_corner" android:state_selected="true">     <item android:drawable="@drawable/bg_white_round_corner" android:state_pressed="false"> </item></item></item></item></selector> This is the gridview codes:                  gvDates.setOnItemClickListener(new OnItemClickListener() { ...

Android Trick - make gridview unscrollable

Damon How to make Android Gridview unscrollable. I found one solution is : GridView .setOnTouchListener( new OnTouchListener(){     public boolean onTouch(View v, MotionEvent event) {         return event.getAction() == MotionEvent. ACTION_MOVE ;     } }); the code means consume the gridview's ACTION_MOVE touch event.

Android Trick - Using intent to Send SMS and come back

Damon In Android we can use Intent to send SMS or calling phone number and something else. System will start default ( Or show a list of apps who can accept this intent ) app. Then if you want to come back to your own application after that you will need this . Intent sendIntent = new Intent(Intent.ACTION_SENDTO);  sendIntent.setData(Uri.parse("sms:" + number)); sendIntent.putExtra("sms_body", smsContent);  sendIntent.putExtra("exit_on_sent", true); startActivity(sendIntent); Not sure whether it also works for the other Intents.