2015年9月3日 星期四

[Test] language

progressDialog
setMessage
setText

[Android ] The most popular code are used in android


// general setting
    final Context context = this;
    AlertDialog.Builder builder;
    private ProgressDialog progressDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

builder = new AlertDialog.Builder(context);
 builder.setMessage("When your IPCam is ready. Press OK to be continued.")
     .setTitle("")
     .setPositiveButton("OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
       int status= new NetworkAccess().isOnline(cm, builder, -1);
       if(status==0){
        exitAddCamera();
       }
      }
     })
     .setNegativeButton("Cancel",
       new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
         dialog.cancel();
        }
       })
     .setOnCancelListener(new DialogInterface.OnCancelListener() {
               @Override 
               public void onCancel(DialogInterface dialog) {
                AddCamera.this.finish();
               }
           }); 


AlertDialog dialog = builder.create();
        dialog.show();



 progressDialog = ProgressDialog.show(context, "Add camera", "Please wait....");

     if(progressDialog!=null){
      progressDialog.dismiss();
     } 


}

2015年9月2日 星期三

[Android] disable scrolling motion in the listview

reference: http://codetheory.in/android-listview-scrolling-viewgroup-hide-disable-scrollbars/

XML Layout

1
android:scrollbars="none"
android:scrollbars will define which scrollbars to display or show any at all. This won’t disable scrolling as such (you’ll be able to scroll in the appropriate direction) but just hide the scrollbars from the user interface. More of a UI switch.
Programatically, you can call View.setVerticalScrollBarEnabled(boolean) andView.setHorizontalScrollBarEnabled(boolean) for similar effect.

Return true from ListView onTouch event

1
2
3
4
5
6
listView.setOnTouchListener(new View.OnTouchListener() {
 
    public boolean onTouch(View v, MotionEvent event) {
        return (event.getAction() == MotionEvent.ACTION_MOVE);
    }
});