Example usage for android.view LayoutInflater inflate

List of usage examples for android.view LayoutInflater inflate

Introduction

In this page you can find the example usage for android.view LayoutInflater inflate.

Prototype

public View inflate(XmlPullParser parser, @Nullable ViewGroup root) 

Source Link

Document

Inflate a new view hierarchy from the specified xml node.

Usage

From source file:li.barter.fragments.PasswordResetFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    init(container, savedInstanceState);
    final View view = inflater.inflate(R.layout.fragment_reset_password, null);

    final Bundle extras = getArguments();

    if (extras != null) {
        mEmailId = extras.getString(Keys.EMAIL);
    }/*from   w w  w . j  a v  a  2 s .c om*/

    mResetButton = (Button) view.findViewById(R.id.button_reset_password);
    mNewPasswordEditText = (EditText) view.findViewById(R.id.edit_text_newpassword);
    mConfirmNewPasswordEditText = (EditText) view.findViewById(R.id.edit_text_confirmpassword);
    mTokenEditText = (EditText) view.findViewById(R.id.edit_text_token);

    mResetButton.setOnClickListener(this);
    return view;
}

From source file:com.example.cuisoap.agrimac.homePage.demand.machineSelectDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    View view = inflater.inflate(R.layout.dialog_select_machine, container);
    list = (ListView) view.findViewById(R.id.machine_select_list);
    adapter = new machineSelectAdapter(mContext);
    data = new ArrayList<>();
    list.setAdapter(adapter);//from w  w w.  j a  va 2  s . com
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            JSONObject jo = new JSONObject();
            HashMap<String, String> item = (HashMap<String, String>) adapter.getItem(position);
            Intent i = new Intent();
            i.setAction("select_machine");
            i.putExtra("id", item.get("id"));
            i.putExtra("name", item.get("machine_name"));
            mContext.sendBroadcast(i);
            dismiss();
        }
    });
    Message m = Message.obtain();
    JSONObject o = new JSONObject();
    try {
        o.put("status", 0);
        JSONArray oo = new JSONArray("[{\n" + "    \"driveType\": \"\",\n"
                + "    \"driverName\": \"p\",\n" + "    \"driverAge\": \"p\",\n"
                + "    \"driverGender\": \"female\",\n" + "    \"driverLicenseType\": \"R\",\n"
                + "    \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n"
                + "    \"machineType\": \"\",\n" + "    \"machineName\": \"p\",\n"
                + "    \"machinePower\": \"1\",\n" + "    \"passengerNum\": \"1\",\n"
                + "    \"wheelDistance\": \"1\",\n" + "    \"checkTime\": \"1\",\n"
                + "    \"payType\": \"loan\",\n" + "    \"machinePowerType\": \"\",\n"
                + "    \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n"
                + "    \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n"
                + "    \"leaseMonth\": \"1\",\n" + "    \"leaseTime\": \"1\",\n"
                + "    \"workCondition\": \"\",\n" + "    \"needType\": \"all\",\n"
                + "    \"houseType\": \"normal_house\",\n" + "    \"id\": \"1\"\n" + "}]");
        o.put("data", oo);
        m.obj = o;
        m.setTarget(h);
        m.sendToTarget();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return view;
}

From source file:com.morphoss.jumble.frontend.CategoryScreenActivity.java

/**
 * This method creates a popup window when a level is unlocked
 *//*from www.  ja  v a 2 s  . c om*/
public void PopupWindowLevel() {

    try {

        LayoutInflater inflater = (LayoutInflater) CategoryScreenActivity.this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.popup_level, (ViewGroup) findViewById(R.id.popup_element));
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        pwindowLevel = new PopupWindow(layout, metrics.widthPixels, metrics.heightPixels, true);
        pwindowLevel.showAtLocation(layout, Gravity.CENTER, 0, 0);
        btnClosePopupLevel = (ImageView) layout.findViewById(R.id.btn_close_popup);
        btnClosePopupLevel.setOnClickListener(cancel_popup_level);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:at.alladin.rmbt.android.map.overlay.RMBTBalloonOverlayView.java

public View setupView(final Context context, final ViewGroup parent) {
    this.context = context;

    // inflate our custom layout into parent
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View v = inflater.inflate(R.layout.balloon_overlay, parent);
    // setup our fields
    //        title = (TextView) v.findViewById(R.id.balloon_item_title);

    resultListView = (LinearLayout) v.findViewById(R.id.resultList);
    resultListView.setVisibility(View.GONE);

    emptyView = (TextView) v.findViewById(R.id.infoText);
    emptyView.setVisibility(View.GONE);

    progessBar = (ProgressBar) v.findViewById(R.id.progressBar);

    return v;/*w w  w. java  2  s. c  o m*/

}

From source file:com.app.sniffy.MainActivity.java

public void showTerms() {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialoglayout = inflater.inflate(R.layout.terms, null);

    WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView);
    webView.loadUrl("file:///android_asset/license.html");

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Terms & Conditions");
    builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox);
                    if (checkBox.isChecked()) {

                        SharedPreferences.Editor editor = settings.edit();
                        editor.putBoolean("userconsent", true);
                        editor.commit();
                        try {
                            new GetKey(context).execute(
                                    new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId
                                            + Utils.getConfigProperty(getResources(), "securekey")));
                        } catch (URISyntaxException e1) {
                            Log.d("main activity key generate", e1.toString());
                        }//  w w w . j a  v  a  2s.  c o m
                    } else {
                        showTerms();
                    }

                }
            });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.autoparts.buyers.activity.InquiryModelActivity.java

private void initOverlay() {
    letterListView = (MyLetterListView) findViewById(R.id.MyLetterListView);
    letterListView.setOnTouchingLetterChangedListener(new LetterListViewListener());
    overlayThread = new OverlayThread();
    handler = new Handler();

    LayoutInflater inflater = LayoutInflater.from(this);
    overlayView = inflater.inflate(R.layout.contact_overlay, null);
    overlay = (TextView) overlayView.findViewById(R.id.mTextView);
    overlayView.setVisibility(View.INVISIBLE);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            PixelFormat.TRANSLUCENT);// w w w.j a  v  a2 s .  com
    WindowManager windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    windowManager.addView(overlayView, lp);
}

From source file:fi.mikuz.boarder.gui.internet.Settings.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_settings);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    @SuppressWarnings("unchecked")
    HashMap<String, String> lastSession = (HashMap<String, String>) getIntent()
            .getSerializableExtra(InternetMenu.LOGIN_KEY);

    try {// w w  w.  j  ava2  s  . c  om
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);
    } catch (NullPointerException e) {
        Toast.makeText(Settings.this, "Please login", Toast.LENGTH_LONG).show();
        Settings.this.finish();
    }

    Button changePassword = (Button) findViewById(R.id.change_password);

    changePassword.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.internet_settings_alert_change_password,
                    (ViewGroup) findViewById(R.id.alert_settings_root));

            final EditText oldPasswordInput = (EditText) layout.findViewById(R.id.oldPasswordInput);
            final EditText newPassword1Input = (EditText) layout.findViewById(R.id.newPassword1Input);
            final EditText newPassword2Input = (EditText) layout.findViewById(R.id.newPassword2Input);
            Button submitButton = (Button) layout.findViewById(R.id.submitButton);

            AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this);
            builder.setView(layout);
            builder.setTitle("Change password");

            submitButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String oldPasswordText = oldPasswordInput.getText().toString();
                    String newPassword1Text = newPassword1Input.getText().toString();
                    String newPassword2Text = newPassword2Input.getText().toString();

                    if (!newPassword1Text.equals(newPassword2Text)) {
                        Toast.makeText(Settings.this, "New passwords don't match", Toast.LENGTH_LONG).show();
                    } else if (newPassword1Text.length() < 6) {
                        Toast.makeText(Settings.this, "Password length must be at least 6 characters",
                                Toast.LENGTH_LONG).show();
                    } else {
                        try {
                            mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG,
                                    false);
                            HashMap<String, String> sendList = new HashMap<String, String>();
                            sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(newPassword1Text));
                            sendList.put(InternetMenu.OLD_PASSWORD_KEY, Security.passwordHash(oldPasswordText));
                            sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                            sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                            new ConnectionManager(Settings.this, InternetMenu.mChangePasswordURL, sendList);
                        } catch (NoSuchAlgorithmException e) {
                            mWaitDialog.dismiss();
                            String msg = "Couldn't make md5 hash";
                            Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show();
                            Log.e(TAG, msg, e);
                        }
                    }
                }
            });

            builder.show();
        }
    });

    Button changeEmail = (Button) findViewById(R.id.change_email);

    changeEmail.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.internet_settings_alert_change_email,
                    (ViewGroup) findViewById(R.id.alert_settings_root));

            final EditText passwordInput = (EditText) layout.findViewById(R.id.passwordInput);
            final EditText newEmailInput = (EditText) layout.findViewById(R.id.newEmailInput);
            Button submitButton = (Button) layout.findViewById(R.id.submitButton);

            AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this);
            builder.setView(layout);
            builder.setTitle("Change email");

            submitButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String passwordText = passwordInput.getText().toString();
                    String newEmailText = newEmailInput.getText().toString();

                    try {
                        mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG,
                                false);
                        HashMap<String, String> sendList = new HashMap<String, String>();
                        sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(passwordText));
                        sendList.put(InternetMenu.EMAIL_KEY, newEmailText);
                        sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                        sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                        new ConnectionManager(Settings.this, InternetMenu.mChangeEmailURL, sendList);
                    } catch (NoSuchAlgorithmException e) {
                        mWaitDialog.dismiss();
                        String msg = "Couldn't make md5 hash";
                        Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show();
                        Log.e(TAG, msg, e);
                    }
                }
            });

            builder.show();
        }
    });

}

From source file:com.intel.xdk.base.Base.java

public void showSplashScreen() {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            //treat displays larger than 6" as tablets
            DisplayMetrics dm = new DisplayMetrics();
            cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
            double x = Math.pow(dm.widthPixels / dm.xdpi, 2);
            double y = Math.pow(dm.heightPixels / dm.ydpi, 2);
            double screenInches = Math.sqrt(x + y);
            if (screenInches > 6) {
                isTablet = true;//from   w w w . j  a  v  a 2 s  . c o m
            }

            //used for calculating status bar height
            int deviceWidth = dm.widthPixels;
            int deviceHeight = dm.heightPixels;
            if (deviceWidth > deviceHeight) {
                deviceWidth = dm.heightPixels;
                deviceHeight = dm.widthPixels;
            }

            //get the splash screen image from asssets
            Bitmap bm = null;
            try {
                if (isTablet) {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen_tablet.jpg");
                } else {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen.jpg");
                }
            } catch (IOException ioe) {
            }

            //if the splash screen assets are missing, don't try to show the splash screen
            if (bm == null) {
                return;
            }

            if (Debug.isDebuggerConnected())
                Log.i("[intel.xdk]", "splash");

            ActivityInfo ai = null;
            int splashViewId = 0;
            try {
                ai = cordova.getActivity().getPackageManager().getActivityInfo(
                        cordova.getActivity().getComponentName(),
                        PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);

                if (isTablet) {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet_ls",
                                "layout", cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet",
                                "layout", cordova.getActivity().getPackageName());
                    }
                } else {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_ls", "layout",
                                cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash", "layout",
                                cordova.getActivity().getPackageName());
                    }
                }
                LayoutInflater inflater = LayoutInflater.from(cordova.getActivity());
                splashView = inflater.inflate(splashViewId, null);

                //set the splash screen image
                //http://stackoverflow.com/questions/7776445/in-android-can-i-use-image-from-assets-in-layout-xml
                ImageView backgroundImage = (ImageView) splashView
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                backgroundImage.setImageBitmap(bm);
                ((ViewGroup) root.getParent()).addView(splashView);
                splashView.bringToFront();

                //hack to fix splash screen size when it is smaller than screen            
                ImageView splashImage = (ImageView) cordova.getActivity()
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                LayoutParams params = splashImage.getLayoutParams();
                Rect imgBounds = splashImage.getDrawable().getBounds();
                int splashHeight = params.height;
                int splashWidth = params.width;

                //make copies in case we have to switch for landscape - not sure if needed, this is a last minute hack
                int deviceWidthCopy, deviceHeightCopy;
                deviceWidthCopy = deviceWidth;
                deviceHeightCopy = deviceHeight;
                if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                    int temp = deviceWidthCopy;
                    deviceWidthCopy = deviceHeightCopy;
                    deviceHeightCopy = temp;
                }
                if (splashHeight < deviceHeightCopy || splashWidth < deviceWidthCopy) {
                    float scaleH = (float) deviceHeightCopy / splashHeight;
                    float scaleW = (float) deviceWidthCopy / splashWidth;
                    float scale = Math.max(scaleH, scaleW);
                    params.height *= scale;
                    params.width *= scale;
                    splashImage.setLayoutParams(params);
                }

                cordova.getActivity().setProgressBarIndeterminateVisibility(true);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

}

From source file:com.coinblesk.client.backup.BackupDialogFragment.java

@Nullable
@Override// w  w  w  .  j a  v  a 2  s. co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_backup_dialog, container);
    txtPassword = (EditText) view.findViewById(R.id.backup_password_text);
    txtPasswordAgain = (EditText) view.findViewById(R.id.backup_password_again_text);
    passwordsMismatchHint = (TextView) view.findViewById(R.id.fragment_backup_passwordmismatch_textview);
    txtPassword.addTextChangedListener(new PasswordsMatchTextWatcher());
    txtPasswordAgain.addTextChangedListener(new PasswordsMatchTextWatcher());

    btnOk = (Button) view.findViewById(R.id.fragment_backup_ok);
    btnOk.setEnabled(false);

    view.findViewById(R.id.fragment_backup_ok).setOnClickListener(new BackupOkClickListener());
    view.findViewById(R.id.fragment_backup_cancel).setOnClickListener(new BackupCancelClickListener());

    return view;
}

From source file:com.aikidonord.fragments.FragmentDate.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_date, null /*container, false*/);

    View rlLoading = view.findViewById(R.id.loadingPanel);
    //View listView = view.getListView();

    if (VerifConnexion.isOnline(this.getActivity())) {
        rlLoading.setVisibility(View.VISIBLE);

        // on va fair l'impasse l dessus vu que je ne suis pas bien sr
        // de la manire dont il faut oprer tant que la vue n'a pas t renvoye.
        //listView.setVisibility(View.GONE);
        this.lancementAsync();
    } else {/*from  w  w  w  .j a v  a2s .c om*/

        AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create();
        alertDialog.setTitle(getResources().getString(R.string.app_name));
        alertDialog.setMessage(getResources().getString(R.string.no_network));
        alertDialog.setIcon(R.drawable.ic_launcher);
        alertDialog.setCancelable(false);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, close
                        // current activity
                        FragmentDate.this.getActivity().finish();
                    }
                });
        alertDialog.show();
    }

    return view;
}