編輯:關於Android編程
5.0系統下的時間選擇器效果圖:
該項目兼容到3.0以下所以用第三方開源項目:actionbarsherlock,動畫效果兼容:nineoldandroids-2.4.0.jar,格式轉換器:joda-time-2.1.jar
主要調用代碼實例:
import org.joda.time.DateTime; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.text.format.DateFormat; import android.widget.Toast; import com.actionbarsherlock.app.SherlockFragmentActivity; import com.doomonafireball.betterpickers.calendardatepicker.CalendarDatePickerDialog; import com.doomonafireball.betterpickers.radialtimepicker.RadialTimePickerDialog; public class MainActivity extends SherlockFragmentActivity implements CalendarDatePickerDialog.OnDateSetListener, RadialTimePickerDialog.OnTimeSetListener { public static final String FRAG_TAG_TIME_PICKER = timePickerDialogFragment; public static final String FRAG_TAG_DATE_PICKER = fragment_date_picker_name; private boolean mHasDialogFrame; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /*FragmentManager fm = getSupportFragmentManager(); DateTime now = DateTime.now(); CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog .newInstance(this, now.getYear(), now.getMonthOfYear() - 1, now.getDayOfMonth()); calendarDatePickerDialog.show(fm, FRAG_TAG_DATE_PICKER);*/ if (savedInstanceState == null) { mHasDialogFrame = findViewById(R.id.frame) != null; } DateTime now = DateTime.now(); RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog .newInstance(this, now.getHourOfDay(), now.getMinuteOfHour(), DateFormat.is24HourFormat(this)); if (mHasDialogFrame) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.frame, timePickerDialog, FRAG_TAG_TIME_PICKER) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .commit(); } else { timePickerDialog.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER); } } @Override public void onResume() { // Example of reattaching to the fragment super.onResume(); /*CalendarDatePickerDialog calendarDatePickerDialog = (CalendarDatePickerDialog) getSupportFragmentManager() .findFragmentByTag(FRAG_TAG_DATE_PICKER); if (calendarDatePickerDialog != null) { calendarDatePickerDialog.setOnDateSetListener(this); }*/ RadialTimePickerDialog rtpd = (RadialTimePickerDialog) getSupportFragmentManager().findFragmentByTag( FRAG_TAG_TIME_PICKER); if (rtpd != null) { rtpd.setOnTimeSetListener(this); } } @Override public void onTimeSet(RadialTimePickerDialog dialog, int hourOfDay, int minute) { // TODO Auto-generated method stub String result= + hourOfDay + : + minute; Toast.makeText(this, result, Toast.LENGTH_SHORT).show(); } @Override public void onDateSet(CalendarDatePickerDialog dialog, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub String result=Year: + year + Month: + monthOfYear + Day: + dayOfMonth; Toast.makeText(this, result, Toast.LENGTH_SHORT).show(); } }
#00000000 #ffffffff #ff4c4c4c #28ffffff #00000000 #46c5c1ff #ff33b5e5 #ff000000 #ffb2b2b2 #28000000 #00000000 #ff00ddff #ff00ddff #ffffff #f2f2f2 #cccccc #8c8c8c #000000 #cccccc #8c8c8c #7f000000 #33b5e5 #c1e8f7 #33999999 #0099cc #ff999999 #999999 #f2f2f2 #ffd1d2d4 #ff3333 #853333 #404040 #363636 #808080 #ffffff #888888 #bfbfbf #fff2f2f2 #ff737373
#cfcfcf
在Android Studio裡面想設置代碼風格,在這裡我想把代碼風格從Java的行尾式改成C風格的代碼,如下 if(true) { // TODO}if
使用Android Sutdio創建一個新的工程後,接下來記錄創建NDK工程的基本步驟。本文將達到:1. 創建NDK工程2. 在JNI中輸出Log語句3. 指定編譯的so
在eclipse中file菜單中選中new--->Android Application Program-->Next --&
Loader(加載器)簡介Android 3.0 中引入了加載器,支持輕松在 Activity 或Fragment中異步加載數據。 加載器具有以下特征:(1)可用於每個