Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void setRemoteShare(final String prof_user, final String prof_pass, final String prof_addr,
        final NotifyEvent p_ntfy) {
    final ArrayList<String> rows = new ArrayList<String>();

    NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override//from   w  ww .ja v a 2  s .  co  m
        public void positiveResponse(Context c, Object[] o) {
            FileListAdapter tfl = (FileListAdapter) o[0];

            for (int i = 0; i < tfl.getCount(); i++) {
                FileListItem item = tfl.getItem(i);
                if (item.isDir() && item.canRead() && !item.getName().startsWith("IPC$")) {
                    String tmp = item.getName();
                    rows.add(tmp);
                }
            }
            if (rows.size() < 1)
                rows.add(getString(R.string.msgs_no_shared_resource));

            //??
            final Dialog dialog = new Dialog(c);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);
            ((TextView) dialog.findViewById(R.id.item_select_list_dlg_title)).setText("Select remote share");
            ((TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle)).setText("");

            CommonDialog.setDlgBoxSizeLimit(dialog, false);

            ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            lv.setAdapter(new ArrayAdapter<String>(c, R.layout.simple_list_item_1m, rows));
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    if (rows.get(idx).startsWith("---"))
                        return;
                    dialog.dismiss();
                    // ????????
                    p_ntfy.notifyToListener(true, new Object[] { rows.get(idx).toString() });
                }
            });
            //CANCEL?
            final Button btnCancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            btnCancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, new Object[] { "" });
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btnCancel.performClick();
                }
            });
            //              dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
            //              dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, new Object[] { "Remote file list creation error" });
        }
    });
    createRemoteFileList("smb://" + prof_addr + "/", ntfy);
    return;
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void createItem(final FileListAdapter fla, final String item_optyp, final String base_dir) {
    sendDebugLogMsg(1, "I", "createItem entered.");

    // ??//from w w w  . j  a va 2 s  . c o m
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.file_rename_create_dlg);
    final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname);
    final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn);
    final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Create directory");
    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name");

    // newName.setText(item_name);

    btnOk.setEnabled(false);
    // btnCancel.setEnabled(false);
    newName.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() < 1)
                btnOk.setEnabled(false);
            else
                btnOk.setEnabled(true);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            if (!checkDuplicateDir(fla, newName.getText().toString())) {
                commonDlg.showCommonDialog(false, "E", "Create", "Duplicate directory name specified", null);
            } else {
                int cmd = 0;
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "",
                            newName.getText().toString(), "", smbUser, smbPass, true);
                    cmd = FILEIO_PARM_LOCAL_CREATE;
                } else {
                    cmd = FILEIO_PARM_REMOTE_CREATE;
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "",
                            newName.getText().toString(), "", smbUser, smbPass, true);
                }
                sendDebugLogMsg(1, "I", "createItem FILEIO task invoked.");
                startFileioTask(fla, cmd, fileioLinkParm, newName.getText().toString(), null, null);
            }
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            sendDebugLogMsg(1, "W", "createItem cancelled.");
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
    //      setFixedOrientation(true);
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void renameItem(final FileListAdapter fla, final String item_optyp, final String item_name,
        final boolean item_isdir, final int item_num) {

    sendDebugLogMsg(1, "I", "renameItem entered.");
    // ??// w  w w  . j a  va  2 s  . co m
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.file_rename_create_dlg);
    final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname);
    final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn);
    final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Rename");
    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name");

    newName.setText(item_name);

    btnOk.setEnabled(false);
    newName.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() < 1 || item_name.equals(s.toString()))
                btnOk.setEnabled(false);
            else
                btnOk.setEnabled(true);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            //            setFixedOrientation(false);
            if (item_name.equals(newName.getText().toString())) {
                commonDlg.showCommonDialog(false, "E", "Rename", "Duplicate file name specified", null);
            } else {
                int cmd = 0;
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                            fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), "", "",
                            true);
                    cmd = FILEIO_PARM_LOCAL_RENAME;
                } else {
                    cmd = FILEIO_PARM_REMOTE_RENAME;
                    if (item_isdir)
                        fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                                fla.getItem(item_num).getPath(), item_name, newName.getText().toString(),
                                smbUser, smbPass, true);
                    else
                        fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                                fla.getItem(item_num).getPath(), item_name, newName.getText().toString(),
                                smbUser, smbPass, true);
                }
                sendDebugLogMsg(1, "I", "renameItem FILEIO task invoked.");
                startFileioTask(fla, cmd, fileioLinkParm, item_name, null, null);
            }
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            //            setFixedOrientation(false);
            sendDebugLogMsg(1, "W", "renameItem cancelled.");
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
    //      setFixedOrientation(true);
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void showFileListCache(final ArrayList<FileListCacheItem> fcl, final FileListAdapter fla,
        final ListView flv, final Spinner spinner) {
    // ??/*w  w  w .j a va  2 s .  c o  m*/
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.select_file_cache_dlg);
    //      final Button btnOk = 
    //            (Button) dialog.findViewById(R.id.select_file_cache_dlg_ok);
    final Button btnCancel = (Button) dialog.findViewById(R.id.select_file_cache_dlg_cancel);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.select_file_cache_dlg_title)).setText("Select file cache");

    ListView lv = (ListView) dialog.findViewById(R.id.select_file_cache_dlg_listview);

    final ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < fcl.size(); i++) {
        list.add(fcl.get(i).directory);
    }
    Collections.sort(list, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return lhs.compareToIgnoreCase(rhs);
        }
    });
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, list);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String t_dir = list.get(position);
            FileListCacheItem dhi = getFileListCache(t_dir, fcl);
            if (dhi != null) {
                mIgnoreSpinnerSelection = true;
                int s_no = -1;
                for (int i = 0; i < spinner.getCount(); i++) {
                    if (spinner.getItemAtPosition(i).toString().equals(dhi.profile_name)) {
                        s_no = i;
                        break;
                    }
                }
                fla.setDataList(dhi.file_list);
                fla.notifyDataSetChanged();
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    localBase = dhi.base;
                    if (dhi.base.equals(dhi.directory))
                        localDir = "";
                    else
                        localDir = dhi.directory.replace(localBase + "/", "");
                    replaceDirHist(localDirHist, dhi.directory_history);
                    setFilelistCurrDir(localFileListDirSpinner, localBase, localDir);
                    setFileListPathName(localFileListPathBtn, localFileListCache, localBase, localDir);
                    setEmptyFolderView();
                    localCurrFLI = dhi;
                    flv.setSelection(0);
                    for (int j = 0; j < localFileListView.getChildCount(); j++)
                        localFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                    localFileListReloadBtn.performClick();
                } else if (currentTabName.equals(SMBEXPLORER_TAB_REMOTE)) {
                    remoteBase = dhi.base;
                    if (dhi.base.equals(dhi.directory))
                        remoteDir = "";
                    else
                        remoteDir = dhi.directory.replace(remoteBase + "/", "");
                    replaceDirHist(remoteDirHist, dhi.directory_history);
                    setFilelistCurrDir(remoteFileListDirSpinner, remoteBase, remoteDir);
                    setFileListPathName(remoteFileListPathBtn, remoteFileListCache, remoteBase, remoteDir);
                    setEmptyFolderView();
                    remoteCurrFLI = dhi;
                    flv.setSelection(0);

                    //                  Log.v("","base="+remoteBase+", dir="+remoteDir+", histsz="+remoteDirHist.size());
                    for (int j = 0; j < remoteFileListView.getChildCount(); j++)
                        remoteFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                    if (remoteDir.equals("")) {
                        remoteFileListTopBtn.setEnabled(false);
                        remoteFileListUpBtn.setEnabled(false);
                    } else {
                        remoteFileListTopBtn.setEnabled(true);
                        remoteFileListUpBtn.setEnabled(true);
                    }
                }

                if (s_no != -1)
                    spinner.setSelection(s_no);
                Handler hndl = new Handler();
                hndl.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mIgnoreSpinnerSelection = false;
                    }
                }, 100);
                dialog.dismiss();
            }
        }
    });

    btnCancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

public void scanRemoteNetworkDlg(final NotifyEvent p_ntfy, String port_number) {
    //??/*from  www .j a  v  a2  s  .  c o m*/
    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.scan_remote_ntwk_dlg);
    final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel);
    final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_msg);
    final TextView tv_result = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_title);
    tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_press_scan_btn));
    tv_result.setVisibility(TextView.GONE);

    final String from = getLocalIpAddress();
    String subnet = from.substring(0, from.lastIndexOf("."));
    String subnet_o1, subnet_o2, subnet_o3;
    subnet_o1 = subnet.substring(0, subnet.indexOf("."));
    subnet_o2 = subnet.substring(subnet.indexOf(".") + 1, subnet.lastIndexOf("."));
    subnet_o3 = subnet.substring(subnet.lastIndexOf(".") + 1, subnet.length());
    final EditText baEt1 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o1);
    final EditText baEt2 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o2);
    final EditText baEt3 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o3);
    final EditText baEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_begin_address_o4);
    final EditText eaEt4 = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_end_address_o4);
    baEt1.setText(subnet_o1);
    baEt2.setText(subnet_o2);
    baEt3.setText(subnet_o3);
    baEt4.setText("1");
    baEt4.setSelection(1);
    eaEt4.setText("254");
    baEt4.requestFocus();

    final CheckBox cb_use_port_number = (CheckBox) dialog.findViewById(R.id.scan_remote_ntwk_use_port);
    final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    if (port_number.equals("")) {
        et_port_number.setEnabled(false);
        cb_use_port_number.setChecked(false);
    } else {
        et_port_number.setEnabled(true);
        et_port_number.setText(port_number);
        cb_use_port_number.setChecked(true);
    }
    cb_use_port_number.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            et_port_number.setEnabled(isChecked);
        }
    });

    final NotifyEvent ntfy_lv_click = new NotifyEvent(mContext);
    ntfy_lv_click.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            dialog.dismiss();
            p_ntfy.notifyToListener(true, o);
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }
    });

    final ArrayList<ScanAddressResultListItem> ipAddressList = new ArrayList<ScanAddressResultListItem>();
    //      ScanAddressResultListItem li=new ScanAddressResultListItem();
    //      li.server_name=mContext.getString(R.string.msgs_ip_address_no_address);
    //      ipAddressList.add(li);
    final ListView lv = (ListView) dialog.findViewById(R.id.scan_remote_ntwk_scan_result_list);
    final AdapterScanAddressResultList adap = new AdapterScanAddressResultList(mContext,
            R.layout.scan_address_result_list_item, ipAddressList, ntfy_lv_click);
    lv.setAdapter(adap);
    lv.setScrollingCacheEnabled(false);
    lv.setScrollbarFadingEnabled(false);

    //SCAN?
    btn_scan.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ipAddressList.clear();
            NotifyEvent ntfy = new NotifyEvent(mContext);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    if (ipAddressList.size() < 1) {
                        tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_not_detected));
                        tv_result.setVisibility(TextView.GONE);
                    } else {
                        tvmsg.setText(mContext.getString(R.string.msgs_scan_ip_address_select_detected_host));
                        tv_result.setVisibility(TextView.VISIBLE);
                    }
                    //                   adap.clear();
                    //                   for (int i=0;i<ipAddressList.size();i++) 
                    //                      adap.add(ipAddressList.get(i));
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                }

            });
            if (auditScanAddressRangeValue(dialog)) {
                tv_result.setVisibility(TextView.GONE);
                String ba1 = baEt1.getText().toString();
                String ba2 = baEt2.getText().toString();
                String ba3 = baEt3.getText().toString();
                String ba4 = baEt4.getText().toString();
                String ea4 = eaEt4.getText().toString();
                String subnet = ba1 + "." + ba2 + "." + ba3;
                int begin_addr = Integer.parseInt(ba4);
                int end_addr = Integer.parseInt(ea4);
                scanRemoteNetwork(dialog, lv, adap, ipAddressList, subnet, begin_addr, end_addr, ntfy);
            } else {
                //error
            }
        }
    });

    //CANCEL?
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            p_ntfy.notifyToListener(false, null);
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    dialog.show();

}

From source file:it.sasabz.android.sasabus.fragments.OnlineSearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater_glob = inflater;
    result = inflater.inflate(R.layout.online_search_layout, container, false);

    Date datum = new Date();
    SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm");

    TextView datetime = (TextView) result.findViewById(R.id.time);
    String datetimestring = "";

    datetimestring = simple.format(datum);

    datetime.setText(datetimestring);// w  w  w . j a  v a  2  s  .c  om

    Button search = (Button) result.findViewById(R.id.search);

    search.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AutoCompleteTextView from = (AutoCompleteTextView) result.findViewById(R.id.from_text);
            AutoCompleteTextView to = (AutoCompleteTextView) result.findViewById(R.id.to_text);
            TextView datetime = (TextView) result.findViewById(R.id.time);

            String from_txt = getThis().getResources().getString(R.string.from_txt);

            if ((!from.getText().toString().trim().equals("")
                    || !from.getHint().toString().trim().equals(from_txt))
                    && !to.getText().toString().trim().equals("")) {
                //Intent getSelect = new Intent(getThis().getActivity(), OnlineSelectStopActivity.class);
                String fromtext = "";
                if (from.getText().toString().trim().equals(""))
                    fromtext = from.getHint().toString();
                else
                    fromtext = from.getText().toString();
                String totext = to.getText().toString();
                fromtext = "(" + fromtext.replace(" -", ")");
                totext = "(" + totext.replace(" -", ")");
                Fragment fragment = new OnlineSelectFragment(fromtext, totext, datetime.getText().toString());
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction ft = fragmentManager.beginTransaction();

                Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment);
                if (old != null) {
                    ft.remove(old);
                }
                ft.add(R.id.onlinefragment, fragment);
                ft.addToBackStack(null);
                ft.commit();
                fragmentManager.executePendingTransactions();
            }
        }
    });

    datetime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            // Create the dialog
            final Dialog mDateTimeDialog = new Dialog(getThis().getActivity());
            // Inflate the root layout
            final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob
                    .inflate(R.layout.date_time_dialog, null);
            // Grab widget instance
            final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView
                    .findViewById(R.id.DateTimePicker);
            TextView dt = (TextView) result.findViewById(R.id.time);
            String datetimestring = dt.getText().toString();

            SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
            Date datetime = null;
            try {
                datetime = datetimeformat.parse(datetimestring);
            } catch (Exception e) {
                ;
            }
            mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes());
            mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate());
            // Check is system is set to use 24h time (this doesn't seem to
            // work as expected though)
            final String timeS = android.provider.Settings.System.getString(
                    getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24);
            final boolean is24h = !(timeS == null || timeS.equals("12"));

            ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime))
                    .setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            mDateTimePicker.clearFocus();
                            String datetimestring = "";
                            int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH);
                            int month = mDateTimePicker.get(Calendar.MONTH) + 1;
                            int year = mDateTimePicker.get(Calendar.YEAR);
                            int hour = 0;
                            int min = 0;
                            int append = 0;
                            if (mDateTimePicker.is24HourView()) {
                                hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY);
                                min = mDateTimePicker.get(Calendar.MINUTE);
                            } else {
                                hour = mDateTimePicker.get(Calendar.HOUR);
                                min = mDateTimePicker.get(Calendar.MINUTE);
                                if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) {
                                    append = 1;
                                } else {
                                    append = 2;
                                }
                            }
                            if (day < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (day + ".");
                            if (month < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (month + "." + year + " ");
                            if (hour < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (hour + ":");
                            if (min < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += min;

                            switch (append) {
                            case 1:
                                datetimestring += " AM";
                                break;
                            case 2:
                                datetimestring += " PM";
                                break;
                            }

                            TextView time = (TextView) result.findViewById(R.id.time);
                            time.setText(datetimestring);
                            mDateTimeDialog.dismiss();
                        }
                    });
            // Cancel the dialog when the "Cancel" button is clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog))
                    .setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimeDialog.cancel();
                        }
                    });

            // Reset Date and Time pickers when the "Reset" button is
            // clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime))
                    .setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimePicker.reset();
                        }
                    });

            // Setup TimePicker
            mDateTimePicker.setIs24HourView(is24h);
            // No title on the dialog window
            mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            // Set the dialog content view
            mDateTimeDialog.setContentView(mDateTimeDialogView);
            // Display the dialog
            mDateTimeDialog.show();
        }

    });

    ImageButton datepicker = (ImageButton) result.findViewById(R.id.datepicker);

    datepicker.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            // Create the dialog
            final Dialog mDateTimeDialog = new Dialog(getThis().getActivity());
            // Inflate the root layout
            final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob
                    .inflate(R.layout.date_time_dialog, null);
            // Grab widget instance
            final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView
                    .findViewById(R.id.DateTimePicker);
            TextView dt = (TextView) result.findViewById(R.id.time);
            String datetimestring = dt.getText().toString();
            SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
            Date datetime = null;
            try {
                datetime = datetimeformat.parse(datetimestring);
            } catch (Exception e) {
                ;
            }
            mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes());
            mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate());
            // Check is system is set to use 24h time (this doesn't seem to
            // work as expected though)
            final String timeS = android.provider.Settings.System.getString(
                    getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24);
            final boolean is24h = !(timeS == null || timeS.equals("12"));

            // Update demo TextViews when the "OK" button is clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime))
                    .setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            mDateTimePicker.clearFocus();
                            String datetimestring = "";
                            int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH);
                            int month = mDateTimePicker.get(Calendar.MONTH) + 1;
                            int year = mDateTimePicker.get(Calendar.YEAR);
                            int hour = 0;
                            int min = 0;
                            int append = 0;
                            if (mDateTimePicker.is24HourView()) {
                                hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY);
                                min = mDateTimePicker.get(Calendar.MINUTE);
                            } else {
                                hour = mDateTimePicker.get(Calendar.HOUR);
                                min = mDateTimePicker.get(Calendar.MINUTE);
                                if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) {
                                    append = 1;
                                } else {
                                    append = 2;
                                }
                            }
                            if (day < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (day + ".");
                            if (month < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (month + "." + year + " ");
                            if (hour < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += (hour + ":");
                            if (min < 10) {
                                datetimestring += "0";
                            }
                            datetimestring += min;

                            switch (append) {
                            case 1:
                                datetimestring += " AM";
                                break;
                            case 2:
                                datetimestring += " PM";
                                break;
                            }

                            TextView time = (TextView) result.findViewById(R.id.time);
                            time.setText(datetimestring);
                            mDateTimeDialog.dismiss();
                        }
                    });
            // Cancel the dialog when the "Cancel" button is clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog))
                    .setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimeDialog.cancel();
                        }
                    });

            // Reset Date and Time pickers when the "Reset" button is
            // clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime))
                    .setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimePicker.reset();
                        }
                    });

            // Setup TimePicker
            mDateTimePicker.setIs24HourView(is24h);
            // No title on the dialog window
            mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            // Set the dialog content view
            mDateTimeDialog.setContentView(mDateTimeDialogView);
            // Display the dialog
            mDateTimeDialog.show();
        }

    });
    from = (AutoCompleteTextView) result.findViewById(R.id.from_text);
    to = (AutoCompleteTextView) result.findViewById(R.id.to_text);

    from.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            InputMethodManager mgr = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(from.getWindowToken(), 0);
        }
    });

    to.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            InputMethodManager mgr = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(to.getWindowToken(), 0);
        }
    });

    LocationManager locman = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE);
    Location lastloc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if (MySQLiteDBAdapter.exists(this.getActivity())) {
        if (lastloc == null) {
            lastloc = locman.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
        if (lastloc != null) {
            try {
                Palina palina = PalinaList.getPalinaGPS(lastloc);
                if (palina != null) {
                    from.setHint(palina.toString());
                }
            } catch (Exception e) {
                Log.e("HomeActivity", "Fehler bei der Location", e);
            }
        } else {
            Log.v("HomeActivity", "No location found!!");
        }
        Vector<DBObject> palinalist = PalinaList.getNameList();
        MyAutocompleteAdapter adapterfrom = new MyAutocompleteAdapter(this.getActivity(),
                android.R.layout.simple_list_item_1, palinalist);
        MyAutocompleteAdapter adapterto = new MyAutocompleteAdapter(this.getActivity(),
                android.R.layout.simple_list_item_1, palinalist);

        from.setAdapter(adapterfrom);
        to.setAdapter(adapterto);
        InputMethodManager mgr = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        mgr.hideSoftInputFromWindow(from.getWindowToken(), 0);
        mgr.hideSoftInputFromWindow(to.getWindowToken(), 0);
    }
    Button favorites = (Button) result.findViewById(R.id.favorites);
    favorites.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SelectFavoritenDialog dialog = new SelectFavoritenDialog(getThis());
            dialog.show();
        }
    });

    Button mappicker = (Button) result.findViewById(R.id.map);
    mappicker.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), MapSelectActivity.class);
            startActivityForResult(intent, REQUESTCODE_ACTIVITY);
        }
    });
    return result;
}