Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:com.htc.dotdesign.ToolBoxService.java

@Override
public void onCreate() {
    Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onCreate");
    super.onCreate();

    Resources res = getResources();
    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
    if (mLocalBroadcastManager != null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(SHOW_HIDE_TOOL_BAR);
        filter.addAction(USER_START_DRAWING);
        mLocalBroadcastManager.registerReceiver(mToolBarReceiver, filter);
    }/* ww  w  . jav a  2 s  .  c  om*/

    // Get full window size
    Display display = mWindowManager.getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    mScreenWidth = size.x;
    mScreenHeight = size.y;

    // Get arrow width
    BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
    bitmapOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(res, R.drawable.dot_design_popupmenu_arrow, bitmapOptions);
    mArrowWidth = bitmapOptions.outWidth;

    // Initialize LayoutParams
    mDragButtonParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.drag_button_width),
            res.getDimensionPixelSize(R.dimen.drag_button_height), WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
    mDragButtonParams.gravity = Gravity.TOP | Gravity.START;
    mDragButtonParams.x = 0;
    mDragButtonParams.y = mScreenHeight / 2;

    mToolBarParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.tool_bar_width),
            res.getDimensionPixelSize(R.dimen.tool_bar_height), WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
    mToolBarParams.alpha = 0.9f;
    mToolBarParams.gravity = Gravity.TOP | Gravity.START;
    mToolBarParams.x = 0;
    mToolBarParams.y = mDragButtonParams.y;

    // Initialize drag button width and height
    //mDragButtonWidth = res.getDimensionPixelSize(R.dimen.drag_button_width);
    mDragButtonHeight = res.getDimensionPixelSize(R.dimen.drag_button_height);
    mDragBtnColorIcon = (GradientDrawable) res.getDrawable(R.drawable.round_button);
    mDragBtnEraserIcon = res.getDrawable(R.drawable.dot_design_circle_shape_dark);

    // Inflate layout
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mDragButton = inflater.inflate(R.layout.drag_button, null);
    mToolBarParent = inflater.inflate(R.layout.tool_bar, null);
    mPalette = inflater.inflate(R.layout.palette, null);
    mEraser = inflater.inflate(R.layout.eraser, null);
    mMenu = inflater.inflate(R.layout.menu, null);

    initToolBar();
    initMenu();
    initAnimation();
    initBrushColor();
    initDragButton();

    mWindowManager.addView(mToolBarParent, mToolBarParams);
    mWindowManager.addView(mDragButton, mDragButtonParams);
    mToolBarParent.setVisibility(View.INVISIBLE);
}

From source file:ca.nehil.rter.streamingapp2.StreamingActivity.java

private void initLayout() {

    /* get size of screen */
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    screenWidth = display.getWidth();/*w w w. j  a  va 2s  . co  m*/
    screenHeight = display.getHeight();
    FrameLayout.LayoutParams layoutParam = null;
    LayoutInflater myInflate = null;
    myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    FrameLayout topLayout = new FrameLayout(this);
    setContentView(topLayout);

    // openGLview
    mGLView = overlay.getGLView();

    /* add camera view */
    // int display_width_d = (int) (1.0 * bg_screen_width * screenWidth /
    // bg_width);
    // int display_height_d = (int) (1.0 * bg_screen_height * screenHeight /
    // bg_height);
    // int prev_rw, prev_rh;
    // if (1.0 * display_width_d / display_height_d > 1.0 * live_width /
    // live_height) {
    // prev_rh = display_height_d;
    // prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
    // } else {
    // prev_rw = display_width_d;
    // prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
    // }
    // layoutParam = new RelativeLayout.LayoutParams(prev_rw, prev_rh);
    // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight /
    // bg_height);
    // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth /
    // bg_width);

    int display_width_d = (int) (1.0 * screenWidth);
    int display_height_d = (int) (1.0 * screenHeight);
    int button_width = 0;
    int button_height = 0;
    int prev_rw, prev_rh;
    if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) {
        prev_rh = display_height_d;
        button_height = display_height_d;
        prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
        button_width = display_width_d - prev_rw;

    } else {
        prev_rw = display_width_d;
        prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
    }

    layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER);
    //layoutParam = new FrameLayout.LayoutParams(prev_rw / 2, prev_rh / 2, Gravity.BOTTOM | Gravity.CENTER_VERTICAL);

    // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight /
    // bg_height);
    // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth /
    // bg_width);
    Log.d("LAYOUT",
            "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:"
                    + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:"
                    + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height);
    cameraDevice = openCamera();
    cameraView = new CameraView(this, cameraDevice);

    topLayout.addView(cameraView, layoutParam);
    topLayout.addView(mGLView, layoutParam);

    FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null);
    layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight);
    topLayout.addView(preViewLayout, layoutParam);
    Log.i(LOG_TAG, "cameara preview start: OK");

    final Button recorderButton = (Button) findViewById(R.id.recorder_control);
    recorderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!recording) {
                Log.d(TAG, "attemptHandshaking");
                attemptHandshake();
                Log.w(LOG_TAG, "Start Button Pushed");
                recorderButton.setText("Stop");
            } else {
                stopRecording();
                Log.w(LOG_TAG, "Stop Button Pushed");
                recorderButton.setText("Start");
            }
        }
    });

}

From source file:in.shick.diode.common.Common.java

/**
 * Helper function to display a list of URLs.
 * @param theContext The current application context.
 * @param settings The settings to use regarding the browser component.
 * @param theItem The ThingInfo item to get URLs from.
 */// w w w  .jav  a 2 s. c o  m
public static void showLinksDialog(final Context theContext, final RedditSettings settings,
        final ThingInfo theItem) {
    assert (theContext != null);
    assert (theItem != null);
    assert (settings != null);
    final ArrayList<String> urls = new ArrayList<String>();
    final ArrayList<MarkdownURL> vtUrls = theItem.getUrls();
    for (MarkdownURL vtUrl : vtUrls) {
        urls.add(vtUrl.url);
    }
    ArrayAdapter<MarkdownURL> adapter = new ArrayAdapter<MarkdownURL>(theContext,
            android.R.layout.select_dialog_item, vtUrls) {
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView tv;
            if (convertView == null) {
                tv = (TextView) ((LayoutInflater) theContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                        .inflate(android.R.layout.select_dialog_item, null);
            } else {
                tv = (TextView) convertView;
            }

            String url = getItem(position).url;
            String anchorText = getItem(position).anchorText;
            //                        if (Constants.LOGGING) Log.d(TAG, "links url="+url + " anchorText="+anchorText);

            Drawable d = null;
            try {
                d = theContext.getPackageManager()
                        .getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            } catch (PackageManager.NameNotFoundException ignore) {
            }
            if (d != null) {
                d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight());
                tv.setCompoundDrawablePadding(10);
                tv.setCompoundDrawables(d, null, null, null);
            }

            final String telPrefix = "tel:";
            if (url.startsWith(telPrefix)) {
                url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length()));
            }

            if (anchorText != null)
                tv.setText(Html.fromHtml("<span>" + anchorText + "</span><br /><small>" + url + "</small>"));
            else
                tv.setText(Html.fromHtml(url));

            return tv;
        }
    };

    AlertDialog.Builder b = new AlertDialog.Builder(
            new ContextThemeWrapper(theContext, settings.getDialogTheme()));

    DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {
        public final void onClick(DialogInterface dialog, int which) {
            if (which >= 0) {
                Common.launchBrowser(settings, theContext, urls.get(which),
                        Util.createThreadUri(theItem).toString(), false, false, settings.isUseExternalBrowser(),
                        settings.isSaveHistory());
            }
        }
    };

    b.setTitle(R.string.select_link_title);
    b.setCancelable(true);
    b.setAdapter(adapter, click);

    b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public final void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    b.show();
}

From source file:com.i2max.i2smartwork.common.work.WorkDetailViewFragment.java

public void setFilesLayout(String title, LinearLayout targetLayout, Object object) {
    final List<LinkedTreeMap<String, String>> filesList = (List<LinkedTreeMap<String, String>>) object;
    if (filesList == null || filesList.size() <= 0) {
        targetLayout.setVisibility(View.GONE);
    } else {/*  ww w .  j a v a2 s  .co  m*/
        Log.e(TAG, "fileList size =" + filesList.size());
        targetLayout.setVisibility(View.VISIBLE);
        targetLayout.removeAllViews();
        //addTitleView
        LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvParam.setMargins(0, DisplayUtil.dip2px(getActivity(), 12), 0, DisplayUtil.dip2px(getActivity(), 10));

        TextView tvTitle = new TextView(getActivity());
        tvTitle.setLayoutParams(tvParam);
        if (Build.VERSION.SDK_INT < 23) {
            tvTitle.setTextAppearance(getActivity(), android.R.style.TextAppearance_Material_Medium);
        } else {
            tvTitle.setTextAppearance(android.R.style.TextAppearance_Material_Medium);
        }
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
        tvTitle.setTextColor(getResources().getColor(R.color.text_color_black));
        tvTitle.setText(title);

        targetLayout.addView(tvTitle);

        //addFilesView
        for (int i = 0; i < filesList.size(); i++) {
            final LinkedTreeMap<String, String> fileMap = filesList.get(i);
            LayoutInflater inflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View fileView = inflater.inflate(R.layout.view_item_file, null);

            ImageView ivIcFileExt = (ImageView) fileView.findViewById(R.id.iv_ic_file_ext);
            TextView tvFileNm = (TextView) fileView.findViewById(R.id.tv_file_nm);

            //??  ? 
            ivIcFileExt.setImageResource(R.drawable.ic_file_doc);
            String fileNm = FormatUtil.getStringValidate(fileMap.get("file_nm"));
            tvFileNm.setText(fileNm);
            FileUtil.setFileExtIcon(ivIcFileExt, fileNm);
            final String fileExt = FileUtil.getFileExtsion(fileNm);
            final String downloadURL = I2UrlHelper.File
                    .getDownloadFile(FormatUtil.getStringValidate(fileMap.get("file_id")));

            fileView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = null;
                    if ("Y".equals(FormatUtil.getStringValidate(fileMap.get("conv_yn")))) {
                        //i2viewer ? ( conv_yn='Y')
                        intent = IntentUtil.getI2ViewerIntent(
                                FormatUtil.getStringValidate(fileMap.get("file_id")),
                                FormatUtil.getStringValidate(fileMap.get("file_nm")));
                        getActivity().startActivity(intent);
                    } else if ("mp4".equalsIgnoreCase(fileExt) || "fla".equalsIgnoreCase(fileExt)
                            || "wmv".equalsIgnoreCase(fileExt) || "avi".equalsIgnoreCase(fileExt)) { //video
                        intent = IntentUtil.getVideoPlayIntent(downloadURL);
                    } else {
                        //? ??
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadURL));
                        Bundle bundle = new Bundle();
                        bundle.putString("Authorization", I2UrlHelper.getTokenAuthorization());
                        intent.putExtra(Browser.EXTRA_HEADERS, bundle);
                        Log.d(TAG, "intent:" + intent.toString());
                    }
                    getActivity().startActivity(intent);

                }
            });

            targetLayout.addView(fileView);
        }

    }
}

From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java

/**
 * Displays the end user license agreement at startup
 *///from   w ww. j a  v a  2 s . c om
private void showEula() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.eula_dialog, null);
    final Dialog dialog;
    builder.setCancelable(false);
    builder.setView(view);
    builder.setTitle(R.string.eula_title);

    builder.setPositiveButton(R.string.agree, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
            editor.putBoolean(Constants.PREF_EULA_ACCEPTED, true);
            editor.commit();

            editor = getPreferences(Context.MODE_PRIVATE).edit();
            editor.putBoolean(Constants.PREF_TRAFFIC_CAMS_INIT, true);
            editor.commit();
            mGetLatestCamerasTask.execute();
        }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
            editor.putBoolean(Constants.PREF_EULA_ACCEPTED, false);
            editor.commit();
            MainActivity.this.finish();
        }
    });

    dialog = builder.create();
    // load the eula from assets
    WebView wv = (WebView) view.findViewById(R.id.web_view_eula);
    wv.loadUrl("file:///android_asset/eula.htm");
    dialog.show();
}

From source file:com.roger.lineselectionwebview.LSWebView.java

/**
 * Creates the selection layer./*from ww  w.j  a v  a  2  s . co m*/
 * 
 * @param context
 */
protected void createSelectionLayer(Context context) {

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);

    // Make sure it's filling parent
    mDragController = new DragController(context);
    mDragController.setDragListener(this);
    mDragController.addDropTarget(mSelectionDragLayer);
    mSelectionDragLayer.setDragController(mDragController);

    mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
    mStartSelectionHandle.setTag(new Integer(SELECTION_START_HANDLE));
    mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
    mEndSelectionHandle.setTag(new Integer(SELECTION_END_HANDLE));

    OnTouchListener handleTouchListener = new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            boolean handledHere = false;

            final int action = event.getAction();

            // Down event starts drag for handle.
            if (action == MotionEvent.ACTION_DOWN) {
                handledHere = startDrag(v);
                mLastTouchedSelectionHandle = (Integer) v.getTag();
            }

            return handledHere;

        }

    };

    mStartSelectionHandle.setOnTouchListener(handleTouchListener);
    mEndSelectionHandle.setOnTouchListener(handleTouchListener);

}

From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java

private void initData() {
    try {//from w w w . j  av  a2s.  c o  m
        usernameET.setText(joDoc.getString("userId"));
        //psdET.setText(joDoc.getString(""));
        nameET.setText(joDoc.getString("name"));
        idET.setText(joDoc.getString("identity"));

        telET.setText(joDoc.getString("phone"));
        mailET.setText(joDoc.getString("email"));
        //TODO ?
        //            workIdEditText.setText(joDoc.getString("workID"));

        sexStr = joDoc.getString("sex");
        birthdayStr = joDoc.getString("birthday");
        yearStr = birthdayStr.substring(0, 4);
        monthStr = birthdayStr.substring(5, 7);
        dayStr = birthdayStr.substring(8);
        Log.i(TAG, "yearString " + yearStr + " monthString " + monthStr + " dayString " + dayStr);

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

    final List<String> yearList = getYearData();
    final List<String> monthList = getMonthData();
    final List<String> dayList = getDayData();
    final List<String> sexList = getSexData();

    ArrayAdapter<String> yearAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            yearList) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(yearList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    ArrayAdapter<String> monthAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getMonthData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(monthList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    ArrayAdapter<String> dayAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getDayData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(dayList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    year.setAdapter(yearAdapter);
    //      year.setSelection(default_year_pos, true);
    month.setAdapter(monthAdapter);
    //      month.setSelection(default_month_pos, true);
    day.setAdapter(dayAdapter);
    //      day.setSelection(default_day_pos, true);

    ArrayAdapter<String> sexAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
            getSexData()) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(sexList.get(position));

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    sex.setAdapter(sexAdapter);
    //        sex.setSelection(default_sex_pos, true);

    //      ArrayAdapter<String> proAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item,namePros){
    //         @Override
    //         public View getDropDownView(int position, View convertView, ViewGroup parent) {
    //            LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //            View view = inflater.inflate(R.layout.spinner_item_layout,
    //                  null);
    //            TextView label = (TextView) view
    //                  .findViewById(R.id.spinner_item_label);
    //
    //            label.setText(namePros[position]);
    //
    //
    //            return view;
    //            //return super.getDropDownView(position, convertView, parent);
    //         }
    //      };
    //      //?
    //
    //      proAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    ////      proAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //      pro.setAdapter(proAdapter);
    //      pro.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    //
    //            @Override
    //            public void onItemSelected(AdapterView<?> parent, View view,
    //                                       int position, long id) {
    //                // TODO Auto-generated method stub
    //                proStr = parent.getItemAtPosition(position).toString();
    //                Log.v(TAG, "selcet proStr:" + proStr);
    //                if (proStr.equals(namePros[position])) {
    //                    idJobTitlesInt = idJobTitles[position];
    //                }
    //            }
    //
    //            @Override
    //            public void onNothingSelected(AdapterView<?> arg0) {
    //                // TODO Auto-generated method stub
    //
    //            }
    //
    //        });
    //        try {
    //            pro.setSelection(joDoc.getInt("jobTitleId")-1,true);
    //        } catch (JSONException e) {
    //            e.printStackTrace();
    //        }

    ArrayAdapter<String> shengAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, nameProvinces) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(nameProvinces[position]);

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };
    //?

    shengAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    sheng.setAdapter(shengAdapter);
    sheng.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> shengparent, View shengview, int shengposition,
                long shengid) {
            // TODO Auto-generated method stub
            myApp.setShengposition(shengposition);
            shengStr = shengparent.getItemAtPosition(shengposition).toString();
            Log.v(TAG, "shengStr:" + shengStr);
            if (shengStr.equals(nameProvinces[shengposition])) {
                Log.v(TAG, "position:" + shengposition);
                for (int i = 0; i < joProvinces.length; i++) {
                    try {

                        if (shengStr.equals(joProvinces[i].getString("name"))) {
                            jaCities = joProvinces[i].getJSONArray("cities");
                            joCities = new JSONObject[jaCities.length()];
                            nameCities = new String[joCities.length];

                            for (int j = 0; j < jaCities.length(); j++) {
                                joCities[j] = jaCities.getJSONObject(j);
                                nameCities[j] = joCities[j].getString("name");
                            }
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block

                        e.printStackTrace();
                    }
                }
            }
            sheng.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {

                    Log.i(TAG, "year touch ");
                    closeSoftKeyboard();
                    return false;
                }
            });
            shiAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item, nameCities) {
                @Override
                public View getDropDownView(int position, View convertView, ViewGroup parent) {
                    LayoutInflater inflater = (LayoutInflater) getContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View view = inflater.inflate(R.layout.spinner_item_layout, null);
                    TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                    label.setText(nameCities[position]);

                    return view;
                    //return super.getDropDownView(position, convertView, parent);
                }
            };

            //?
            shiAdapter.setDropDownViewResource(R.layout.spinner_item_layout);

            //            shiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            shi.setAdapter(shiAdapter);

            shi.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> shiparent, View shiview, int shiposition,
                        long shiid) {
                    // TODO Auto-generated method stub
                    shiStr = shiparent.getItemAtPosition(shiposition).toString();
                    Log.v(TAG, "shiStr:" + shiStr);
                    if (shiStr.equals(nameCities[shiposition])) {
                        for (int i = 0; i < joCities.length; i++) {
                            try {
                                if (shiStr.equals(joCities[i].getString("name"))) {
                                    jaHospitals = joCities[i].getJSONArray("hospitals");
                                    joHospitals = new JSONObject[jaHospitals.length()];
                                    nameHospitals = new String[joHospitals.length];
                                    for (int j = 0; j < jaHospitals.length(); j++) {
                                        joHospitals[j] = jaHospitals.getJSONObject(j);
                                        nameHospitals[j] = joHospitals[j].getString("name");
                                    }

                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block

                                e.printStackTrace();
                            }
                        }
                    }
                    shi.setOnTouchListener(new View.OnTouchListener() {
                        @Override
                        public boolean onTouch(View view, MotionEvent motionEvent) {

                            Log.i(TAG, "year touch ");
                            closeSoftKeyboard();
                            return false;
                        }
                    });
                    hospitalAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, R.layout.spinner_item,
                            nameHospitals) {
                        @Override
                        public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            LayoutInflater inflater = (LayoutInflater) getContext()
                                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            View view = inflater.inflate(R.layout.spinner_item_layout, null);
                            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                            label.setText(nameHospitals[position]);

                            return view;
                            //return super.getDropDownView(position, convertView, parent);
                        }
                    };

                    //?
                    hospitalAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                    yy.setAdapter(hospitalAdapter);

                    yy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> yyparent, View yyview, int yyposition,
                                long yyid) {
                            // TODO Auto-generated method stub
                            yyStr = yyparent.getItemAtPosition(yyposition).toString();
                            if (yyStr.equals(nameHospitals[yyposition])) {
                                for (int i = 0; i < joHospitals.length; i++) {
                                    try {
                                        if (yyStr.equals(joHospitals[i].getString("name"))) {
                                            jaDepartments = joHospitals[i].getJSONArray("departments");
                                            joDepartments = new JSONObject[jaDepartments.length()];
                                            nameDepartments = new String[joDepartments.length];
                                            idDepartments = new int[joDepartments.length];
                                            for (int j = 0; j < jaDepartments.length(); j++) {
                                                joDepartments[j] = jaDepartments.getJSONObject(j);
                                                nameDepartments[j] = joDepartments[j].getString("name");
                                                idDepartments[j] = joDepartments[j].getInt("id");

                                            }

                                        }
                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block

                                        e.printStackTrace();
                                    }
                                }
                            }
                            yy.setOnTouchListener(new View.OnTouchListener() {
                                @Override
                                public boolean onTouch(View view, MotionEvent motionEvent) {

                                    Log.i(TAG, "year touch ");
                                    closeSoftKeyboard();
                                    return false;
                                }
                            });
                            //                                departmentAdapter = new ArrayAdapter<String>(ModifyInfoActivity.this, android.R.layout.simple_spinner_item, nameDepartments) {
                            //                                    @Override
                            //                                    public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            //                                        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            //                                        View view = inflater.inflate(R.layout.spinner_item_layout,
                            //                                                null);
                            //                                        TextView label = (TextView) view
                            //                                                .findViewById(R.id.spinner_item_label);
                            //
                            //                                        label.setText(nameDepartments[position]);
                            //
                            //
                            //                                        return view;
                            //                                        //return super.getDropDownView(position, convertView, parent);
                            //                                    }
                            //                                };
                            //
                            //                                ?
                            //                                departmentAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                            //                                ks.setAdapter(departmentAdapter);
                            //                                try {
                            //                                    ks.setSelection(joDoc.getInt("departmentId") - 1, true);
                            //                                } catch (JSONException e) {
                            //                                    e.printStackTrace();
                            //                                }
                            //                                ks.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            //
                            //                                    @Override
                            //                                    public void onItemSelected(
                            //                                            AdapterView<?> ksparent, View ksview,
                            //                                            int ksposition, long ksid) {
                            //                                        // TODO Auto-generated method stub
                            //                                        ksStr = ksparent.getItemAtPosition(ksposition).toString();
                            //                                        if (ksStr.equals(nameDepartments[ksposition])) {
                            //                                            try {
                            //                                                idDepartmentInt = idDepartments[ksposition];
                            //                                                joDepartmentType = joDepartments[ksposition].getJSONObject("departmentType");
                            //                                                departmentTypeTv.setText(joDepartmentType.getString("name"));
                            //                                            } catch (JSONException e) {
                            //                                                // TODO Auto-generated catch block
                            //
                            //                                                e.printStackTrace();
                            //                                            }
                            //                                        }
                            //                                    }
                            //
                            //
                            //                                    @Override
                            //                                    public void onNothingSelected(
                            //                                            AdapterView<?> arg0) {
                            //                                        // TODO Auto-generated method stub
                            //
                            //                                    }
                            //                                });
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                            // TODO Auto-generated method stub

                        }
                    });
                    //                        ks.setOnTouchListener(new View.OnTouchListener() {
                    //                            @Override
                    //                            public boolean onTouch(View view, MotionEvent motionEvent) {
                    //
                    //                                Log.i(TAG, "year touch ");
                    //                                closeSoftKeyboard();
                    //                                return false;
                    //                            }
                    //                        });
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                    // TODO Auto-generated method stub

                }
            });

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });
    year.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            yearStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    month.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            monthStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    day.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            dayStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    sex.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            sexStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });

    for (int i = 0; i < sexList.size(); i++) {
        if (sexList.get(i).equals(sexStr)) {
            sex.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < yearList.size(); i++) {
        if (yearList.get(i).equals(yearStr)) {
            year.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < monthList.size(); i++) {
        if (monthList.get(i).equals(monthStr)) {
            month.setSelection(i, true);
            break;
        }
    }
    for (int i = 0; i < dayList.size(); i++) {
        if (dayList.get(i).equals(dayStr)) {
            day.setSelection(i, true);
            break;
        }
    }
    photoBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            picKind = 0;
            //                startActivityForResult(new Intent(ModifyInfoActivity.this, SelectPictureActivity.class), REQUEST_PICK);

            Intent intent = new Intent(ModifyInfoActivity.this, SelectPictureActivity.class);
            intent.putExtra("from", "modify");
            startActivityForResult(intent, REQUEST_PICK);
            //RegisterActivity.this.finish();
        }
    });

    signBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            picKind = 1;
            //                startActivityForResult(new Intent(ModifyInfoActivity.this, SelectPictureActivity.class), REQUEST_PICK);
            Intent intent = new Intent(ModifyInfoActivity.this, SelectPictureActivity.class);
            intent.putExtra("from", "modify");
            startActivityForResult(intent, REQUEST_PICK);
        }
    });

    regBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            modify();

        }
    });

}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void init(AttributeSet attrs) {

    mHostActivity = getHostActivity();/*from ww w. jav  a 2  s. c om*/

    LayoutInflater layoutInflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    inflate(getContext(), R.layout.floating_search_layout, this);

    mBackgroundDrawable = new ColorDrawable(Color.BLACK);

    mQuerySection = findViewById(R.id.search_query_section);
    mVoiceInputOrClearButton = (ImageView) findViewById(R.id.search_bar_mic_or_ex);
    mSearchInput = (EditText) findViewById(R.id.search_bar_text);
    mSearchBarTitle = (TextView) findViewById(R.id.search_bar_title);
    mMenuSearchOrExitButton = (ImageView) findViewById(R.id.search_bar_exit);
    mSearchProgress = (ProgressBar) findViewById(R.id.search_bar_search_progress);
    mShowMenuAction = true;
    mOverflowMenu = (ImageView) findViewById(R.id.search_bar_overflow_menu);
    mMenuBuilder = new MenuBuilder(getContext());
    mMenuPopupHelper = new MenuPopupHelper(getContext(), mMenuBuilder, mOverflowMenu);
    initDrawables();
    mVoiceInputOrClearButton.setImageDrawable(mIconMic);
    mOverflowMenu.setImageDrawable(mIconOverflowMenu);

    mDivider = findViewById(R.id.divider);

    mSuggestionsSection = (RelativeLayout) findViewById(R.id.search_suggestions_section);
    mSuggestionListContainer = findViewById(R.id.suggestions_list_container);
    mSuggestionsList = (RecyclerView) findViewById(R.id.suggestions_list);

    setupViews(attrs);
}

From source file:mx.com.adolfogarcia.popularmovies.model.view.MovieDetailViewModel.java

/**
 * Removes all views from the {@link LinearLayout} and adds new ones for
 * the specified {@link Trailer}s./*  w w w .  j  a v  a2 s. c o  m*/
 *
 * @param container {@link LinearLayout} that will contain the trailers.
 * @param trailers the {@link Trailer}s to be placed in the container.
 */
@BindingAdapter({ "bind:trailers" })
public static void loadTrailerViews(LinearLayout container, List<Trailer> trailers) {
    container.removeAllViews();
    if (trailers == null || trailers.isEmpty()) {
        return;
    }
    LayoutInflater inflater = (LayoutInflater) container.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    for (Trailer trailer : trailers) {
        MovieTrailerListItemBinding binding = DataBindingUtil.inflate(inflater,
                R.layout.list_item_movie_trailer, container, false);
        MovieTrailerListItemViewModel itemViewModel = new MovieTrailerListItemViewModel();
        itemViewModel.setTrailer(trailer);
        binding.setViewModel(itemViewModel);
        container.addView(binding.getRoot());
    }
}