Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

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

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:org.linphone.LinphoneService.java

void addFloatingWindows() {
    view = LayoutInflater.from(this).inflate(R.layout.callingactivity, null);
    windowManager = (WindowManager) this.getSystemService(WINDOW_SERVICE);
    /*/*from w w w  .ja  v a  2s. c o m*/
     * LayoutParams.TYPE_SYSTEM_ERRORView
     * LayoutParams.FLAG_NOT_FOCUSABLE:
     * PixelFormat.TRANSPARENT
     */
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
            LayoutParams.TYPE_SYSTEM_ERROR, LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);
    // layoutParams.gravity = Gravity.RIGHT|Gravity.BOTTOM; //
    layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
    layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

    final Button Answer = (Button) view.findViewById(R.id.buttonAnswer);
    Answer.setVisibility(View.VISIBLE);
    Answer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
            if (lLinphoneCore.isInComingInvitePending()) {
                try {
                    lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall());
                    Answer.setVisibility(View.GONE);
                } catch (LinphoneCoreException e) {
                    lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
                    // Toast toast = Toast.makeText(DialerActivity.this
                    // ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
                    // ,Toast.LENGTH_LONG);
                    // toast.show();
                    //                  finish();
                }
                return;
            }
        }
    });

    Button guaDuanDianhua = (Button) view.findViewById(R.id.buttonGuaDuanDianhua);
    guaDuanDianhua.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //            LinphoneCore lLinphoneCore = LinphoneService.instance()
            //                  .getLinphoneCore();
            //            lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
            //            Intent intent = new Intent();
            //            intent.setClass(CallingActivity.this, CallEndActivity.class);
            //            startActivity(intent);
            //            finish();
            try {
                Log.i("mayingcai", "classType: ");

                Class classType = Class.forName("com.android.internal.telephony.ITelephony");
                Log.i("mayingcai", "classType: 1");
                Object invokeTester = classType.newInstance();
                Log.i("mayingcai", "classType: 2");
                Method addMethod = classType.getMethod("endCall", null);
                Log.i("mayingcai", "classType: 3");
                addMethod.invoke(invokeTester);
                Log.i("mayingcai", "classType: 4");

            } catch (Exception e) {
                // TODO Auto-generated catch block
                Log.i("mayingcai", "classType: 5");
                e.printStackTrace();
            }
        }
    });

    windowManager.addView(view, layoutParams);
}

From source file:com.actionbarsherlock.internal.widget.ActionBarView.java

private void initTitle() {
    if (mTitleLayout == null) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abs__action_bar_title_item, this, false);
        mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
        mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
        mTitleUpView = mTitleLayout.findViewById(R.id.abs__up);

        mTitleLayout.setOnClickListener(mUpClickListener);

        if (mTitleStyleRes != 0) {
            mTitleView.setTextAppearance(mContext, mTitleStyleRes);
        }//from   ww w  . j ava  2s .co  m
        if (mTitle != null) {
            mTitleView.setText(mTitle);
        }

        if (mSubtitleStyleRes != 0) {
            mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
        }
        if (mSubtitle != null) {
            mSubtitleView.setText(mSubtitle);
            mSubtitleView.setVisibility(VISIBLE);
        }

        final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
        final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
        mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
        mTitleLayout.setEnabled(homeAsUp && !showHome);
    }

    addView(mTitleLayout);
    if (mExpandedActionView != null || (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
        // Don't show while in expanded mode or with empty text
        mTitleLayout.setVisibility(GONE);
    }
}

From source file:com.code.android.vibevault.SearchScreen.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.nowPlaying: //Open playlist activity
        Intent np = new Intent(SearchScreen.this, NowPlayingScreen.class);
        //Intent np = new Intent(SearchScreen.this, HomeScreen.class);

        startActivity(np);// w  w  w  .  ja  v  a 2s. co m
        break;
    case R.id.recentShows:
        Intent rs = new Intent(SearchScreen.this, RecentShowsScreen.class);

        startActivity(rs);
        break;
    case R.id.scrollableDialog:
        AlertDialog.Builder ad = new AlertDialog.Builder(this);
        ad.setTitle("Help!");
        View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null);
        ((TextView) v.findViewById(R.id.DialogText)).setText(R.string.search_screen_help);
        ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int arg1) {
            }
        });
        ad.setView(v);
        ad.show();
    }
    return true;
}

From source file:com.azita.iot.ioclient.activity.MainActivity.java

public void showDialog_lightingdimmer(View view) {
    View dialogView = LayoutInflater.from(this).inflate(R.layout.share_bottom_dialog_lightingdimmer, null);
    final ShareBottomPopupDialog shareBottomPopupDialog = new ShareBottomPopupDialog(this, dialogView);
    shareBottomPopupDialog.showPopup(all_layout);

    SeekBar light_dimmer_1_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_1_seekbar);
    light_dimmer_1_seekbar.setProgress(_Lightingdimmer_1_value);
    light_dimmer_1_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override//from   www  .  ja v a2  s  .c  o m
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_1_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #1 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_1_value = _Lightingdimmer_1_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_2_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_2_seekbar);
    light_dimmer_2_seekbar.setProgress(_Lightingdimmer_2_value);
    light_dimmer_2_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_2_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #2 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_2_value = _Lightingdimmer_2_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_3_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_3_seekbar);
    light_dimmer_3_seekbar.setProgress(_Lightingdimmer_3_value);
    light_dimmer_3_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_3_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #3 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_3_value = _Lightingdimmer_3_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_4_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_4_seekbar);
    light_dimmer_4_seekbar.setProgress(_Lightingdimmer_4_value);
    light_dimmer_4_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_4_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #4 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_4_value = _Lightingdimmer_4_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
}

From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java

private void showSetIconWindow() {
    View contentView = LayoutInflater.from(this).inflate(R.layout.view_set_icon_popwindow, null);
    View parentView = LayoutInflater.from(this).inflate(R.layout.business_my_center_activity, null);

    setIconWindow = PopupWindowFromBottomUtil.showWindow(contentView, parentView, this);

    Button btnCancel = (Button) contentView.findViewById(R.id.btnCancel);
    Button btnCamera = (Button) contentView.findViewById(R.id.btnCamera);
    Button btnAlbum = (Button) contentView.findViewById(R.id.btnAlbum);

    btnCancel.setOnClickListener(this);
    btnCamera.setOnClickListener(this);
    btnAlbum.setOnClickListener(this);
}

From source file:ab.util.AbDialogUtil.java

/**
 * progressDialog//from  w  w w.j av  a 2 s .co  m
 * 
 * @param context
 * @param msg
 * @return
 */
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(R.layout.herily_alertex_dialog_custom_frame_layout, null);// view
    ProgressWheel spaceshipImage = (ProgressWheel) v.findViewById(R.id.customFrameLoadImg);
    spaceshipImage.stopSpinning();
    spaceshipImage.startSpinning();
    TextView tipTextView = (TextView) v.findViewById(R.id.customFrameMsg);// ??
    tipTextView.setText(msg);// ?
    Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// ?dialog
    loadingDialog.setCancelable(false);// ????
    loadingDialog.setContentView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT));// 
    return loadingDialog;
}

From source file:dentex.youtube.downloader.DashboardActivity.java

private void rename(final DashboardListItem currentItem) {
    AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper);
    LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this);
    View inputFilename = adbInflater.inflate(R.layout.dialog_input_filename, null);
    userFilename = (TextView) inputFilename.findViewById(R.id.input_filename);
    userFilename.setText(currentItem.getFilename());
    adb.setView(inputFilename);/* ww w.  jav  a  2 s.  co  m*/
    adb.setTitle(getString(R.string.rename_dialog_title));
    //adb.setMessage(getString(R.string.rename_dialog_msg));

    adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String input = userFilename.getText().toString();
            File in = new File(currentItem.getPath(), currentItem.getFilename());
            File renamed = new File(currentItem.getPath(), input);
            if (in.renameTo(renamed)) {
                // set new name to the list item
                currentItem.setFilename(input);

                // update the JSON file entry
                Json.addEntryToJsonFile(DashboardActivity.this, currentItem.getId(), currentItem.getType(),
                        currentItem.getYtId(), currentItem.getPos(), currentItem.getStatus(),
                        currentItem.getPath(), input, Utils.getFileNameWithoutExt(input),
                        currentItem.getAudioExt(), currentItem.getSize(), false);

                // remove references for the old file
                String mediaUriString = Utils.getContentUriFromFilePath(in.getAbsolutePath(),
                        getContentResolver());
                //Utils.logger("d", "mediaString: " + mediaUriString, DEBUG_TAG);
                removeFromMediaStore(in, mediaUriString);

                // scan the new file
                Utils.scanMedia(DashboardActivity.this, new String[] { renamed.getAbsolutePath() },
                        new String[] { "video/*" });

                // refresh the dashboard
                refreshlist(DashboardActivity.this);

                Utils.logger("d", "'" + in.getName() + "' renamed to '" + input + "'", DEBUG_TAG);
            } else {
                Log.e(DEBUG_TAG, "'" + in.getName() + "' NOT renamed");
            }

            // hide keyboard
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(userFilename.getWindowToken(), 0);
        }
    });

    adb.setNegativeButton(getString(R.string.dialogs_negative), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // cancel
        }
    });

    secureShowDialog(adb);
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void DoFlightMember() {
    // get member_list.xml view
    LayoutInflater li = LayoutInflater.from(context);
    membersView = li.inflate(R.layout.member_list, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    // set member_list.xml to alertdialog builder
    alertDialogBuilder.setView(membersView);
    ///*from  w w  w.ja v a  2  s  . com*/
    Button mMember_Btn;
    final EditText mDetailInfo;
    Button mGlider_Btn;
    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (!fPilo.equals("") && !fRegi.equals("")) {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = fRegiPilo + ":" + MemberIndexList.get(i);
                    }
                }
                DoFlightFilter(7, fRegiPilo);
                OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                        R.id.action_45min);
            } else if (!fRegi.equals("")) {
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        // set filter criteria for selected member
                        DoFlightFilter(6, GliderList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            } else if (!fPilo.equals("")) {
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        // set filter criteria for selected member
                        DoFlightFilter(5, MemberIndexList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            DoFlightFilter(4, "");
            OptionSelect(R.id.action_all, R.id.action_my, R.id.action_open, R.id.action_ready,
                    R.id.action_45min);
            dialog.cancel();
        }
    });
    AlertDialog alertDialog = alertDialogBuilder.create();
    // get reference to and fill spinner with members
    mMemberSpin = (Spinner) membersView.findViewById(R.id.flight_member);
    ArrayAdapter<String> dataAdapter_1 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, MemberList);
    dataAdapter_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMemberSpin.setAdapter(dataAdapter_1);
    // get reference to and fill spinner with gliders
    mGliderSpin = (Spinner) membersView.findViewById(R.id.flight_glider);
    ArrayAdapter<String> dataAdapter_2 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, GliderList);
    dataAdapter_2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mGliderSpin.setAdapter(dataAdapter_2);
    mDetailInfo = (EditText) membersView.findViewById(R.id.editText1);
    // make field read only
    mDetailInfo.setClickable(false);
    mDetailInfo.setFocusable(false);
    mGlider_Btn = (Button) membersView.findViewById(R.id.flight_glider_detail);
    mGlider_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            if (fRegi.equals(null) || fRegi.equals("")) {
                mDetailInfo.setText("Geen Registratie selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_GLIDER, fRegiPilo, 0));
            }
        }
    });
    mMember_Btn = (Button) membersView.findViewById(R.id.flight_member_detail);
    mMember_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (fPilo.equals(null) || fPilo.equals("")) {
                mDetailInfo.setText("Geen Naam selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = MemberIndexList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_MEMBER, fRegiPilo, 1));
            }
        }
    });
    alertDialog.show();
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

@Override
public void installViewFactory() {
    LayoutInflater layoutInflater = LayoutInflater.from(mContext);
    if (layoutInflater.getFactory() == null) {
        LayoutInflaterCompat.setFactory(layoutInflater, this);
    } else {//from  w ww. j  ava 2  s.c o  m
        if (!(LayoutInflaterCompat.getFactory(layoutInflater) instanceof AppCompatDelegateImplV7)) {
            Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed"
                    + " so we can not install AppCompat's");
        }
    }
}