忍受我,因爲這是我的第一個應用程序。我的應用程序不是太革命,但我想通過實現一些自定義選擇器來使其更加用戶友好。例如,一個使用日曆選取器的日曆選取器,或使用水平流動的類似Spinner的選取器(很像SetCPU)。不幸的是,我甚至不知道從哪裏開始構建像這樣的自定義UI組件。創建自定義android拾取器
4
A
回答
0
好了,我已經決定放棄現在,而是爲別人這個網頁真的幫我至少換我的頭周圍。
http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/
2
Android的默認小部件很簡單,但通過混合它們,您可以構建自己的自定義小部件。 Read more about this here.
0
創建一個擴展視圖的自定義類。然後,您可以設置尺寸並控制畫布上繪製的內容以及它如何響應觸摸事件。關於創建「小部件」有很多例子。 Reto Meiers書中有一個很好的例子,他創建了一個指南針。
4
我想下面的骨架代碼將有助於在你的應用程序中提供一些你需要的靈活性。
/* Simple Dialog
Dialog dialog = new Dialog(this);
dialog.setTitle("Hello");
dialog.show();
*/
/* Inflating an layout as the Dialog
Dialog loginDialog = new Dialog(this);
View layout = LayoutInflater.from(this).inflate(R.layout.login, null);
loginDialog.setContentView(layout);
Button btn = (Button)(layout.findViewById(R.id.button1));
final EditText txt = (EditText) layout.findViewById(R.id.editText1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//Toast.makeText(getApplicationContext(), txt.getText().toString(), Toast.LENGTH_SHORT).show();
txt.setText("Ahmedabad");
}
});
loginDialog.show();
/* ProgreessBar Dialog (you need to implement thread)
ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(2);
dialog.show();
*/
/* Alert Dialog to alert a mesage or an error or customize exception like Enter the field, etc.
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setMessage("Message");
dialog.setIcon(R.drawable.ic_launcher);
dialog.setTitle("Done");
dialog.show();
*/
/* ------------------- Binding array items into the spinner ---------------------------
sp = (Spinner)findViewById(R.id.spinner1);
String bloodgroups[]={
"A +ve","B +ve","O +ve","AB +ve","A -ve","B -ve","O -ve","AB -ve"
};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout .simple_spinner_dropdown_item,bloodgroups);
sp.setAdapter(adapter);
*/
/* DatePicker Dialog Code: I have used a button whose click event bring datepicker dialog into focus
Button btnselDate = (Button)findViewById(R.id.btnseldate); // date select button
// ----------------------------- DATE PICKER DIALOG PROMPT ---------------------
btnselDate.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
showDialog(1);
}
});
@Override
protected Dialog onCreateDialog(int id) {
DatePickerDialog dialog = new DatePickerDialog(this, new OnDateSetListener()
{
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
((EditText)findViewById(R.id.txtdate)).setText(dayOfMonth + "/" + monthOfYear + "/" + year);
}
}, new GregorianCalendar().get(Calendar.YEAR), new GregorianCalendar().get(Calendar.MONTH), new GregorianCalendar().get(Calendar.DAY_OF_MONTH));
return dialog;
}
*/
相關問題
- 1. 爲Android創建自定義瀏覽器
- 2. Android創建自定義適配器
- 3. Android:創建自定義欄
- 4. Android創建自定義onMarkerClickListener
- 5. 創建自定義android rom
- 6. 創建自定義Android ROM
- 7. 自定義鉻源代碼爲android創建自定義瀏覽器
- 8. 在Android中創建自定義EditText
- 9. 創建自定義Android鍵盤佈局
- 10. 如何創建自定義的edittextbox android?
- 11. android創建自定義形狀佈局
- 12. Android Release KeyStore創建自定義
- 13. 創建自定義平面開關android
- 14. 的Android創建自定義維度
- 15. Android中創建自定義BaseAdapter 2.3.3
- 16. 創建自定義視圖需要Android
- 17. 在android中創建自定義佈局
- 18. Android創建自定義按鈕
- 19. 創建自定義凸形路徑Android
- 20. Android - 創建自定義複合組件
- 21. 創建Android自定義視圖
- 22. 創建自定義的Android活動
- 23. 在Android中創建自定義視圖
- 24. 創建自定義帳戶Android
- 25. 創建自定義視圖,Android Studio
- 26. 爲android創建自定義鍵盤
- 27. 在android中創建自定義通知
- 28. 在Android中創建自定義佈局
- 29. 爲Android創建自定義小部件
- 30. Android:自定義視圖創建教程
@mango:請記住我的答案,如果合適,你找到答案的價值,並回答你的問題。 – Rushabh