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:app.hacked.ChallengeListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.challenge_list_fragment, null);
    progressBar = view.findViewById(R.id.progressBar);
    return view;//from ww w  .  j a  v  a 2s  .c  o m
}

From source file:it.crs4.most.ehrlib.widgets.DvQuantityWidget.java

/**
 * Instantiates a new {@link DvQuantityWidget}
 *
 * @param provider the widget provider/*from w  w w  .j  a v  a2 s. c  om*/
 * @param name the name of this widget
 * @param path the path of the {@link DvQuantity} mapped on this widget
 * @param attributes the attributes of the {@link DvQuantity} mapped on this widget
 * @param parentIndex the parent index
 */
public DvQuantityWidget(WidgetProvider provider, String name, String path, JSONObject attributes,
        int parentIndex) {
    super(provider, name, new DvQuantity(path, attributes), parentIndex);

    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.dv_quantity, null);

    _root_view = view;
    _labUnity = (TextView) _root_view.findViewById(R.id.txt_units);
    _title = (TextView) _root_view.findViewById(R.id.txt_title);
    _txtvalidity = (TextView) _root_view.findViewById(R.id.txt_validity);
    _input = (EditText) _root_view.findViewById(R.id.txt_magnitude);

    this.updateLabelsContent();

    _help = (ImageView) _root_view.findViewById(R.id.image_help);

    toolTipRelativeLayout = (ToolTipRelativeLayout) _root_view
            .findViewById(R.id.activity_main_tooltipRelativeLayout);

    _help.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (myToolTipView == null) {
                myToolTipView = toolTipRelativeLayout.showToolTipForView(toolTip, _help);
                //myToolTipView.setOnToolTipViewClickedListener(DvTextWidget.this);
            } else {
                myToolTipView.remove();
                myToolTipView = null;

            }
        }
    });

    Log.d(TAG, "DV QUANTITY VALUE: " + datatype.getMagnitude());
    setupEditingFilters();
    updateWidgetContents();
}

From source file:edu.illinois.whereru.MainPageActivity.java

private void showRegistrationDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater factory = LayoutInflater.from(this);
    // inflate dialog view
    View view = factory.inflate(R.layout.dialog_user_registration, null);
    // Setting dialog message and title
    builder.setMessage(R.string.register_dialog_message).setTitle(R.string.register_dialog_title);
    // set custom view
    builder.setView(view);/*from ww w  .  ja  va2 s . co m*/

    // need to get the edittext from dialog layout
    // calling findViewById automatically searches the layout attached to this activity
    editText = (EditText) view.findViewById(R.id.dialog_username_text);
    preferenceEditor = userInfo.edit();

    builder.setPositiveButton(R.string.register_button_text, new OnClickListener() {

        public void onClick(DialogInterface dialogs, int id) {
            String userName = editText.getText().toString();
            // TODO need to figure out a way to define a user with unique id
            String deviceID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

            // Connect to DB and store a new user
            DBConnector dbConnector = new DBConnector();
            dbConnector.execute(DBConnector.ADD_USER, userName, deviceID);
            JSONObject result = null;

            // Wait for the feedback from the DB
            try {
                result = dbConnector.get();
            } catch (InterruptedException e) {
                // shouldn't be interrupted
                Log.e(DEBUG_TAG, "Interrupted, restarting");
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

            boolean successful = false;
            String userId = null;

            // Parse the response returned from DB
            if (result != null) {
                successful = JSONObjectParser.getSuccess(result);
                userId = JSONObjectParser.getUserId(result) + "";
            }

            if (successful) { // Store user info locally
                // user id returned from DB
                preferenceEditor.putString(PREF_USER_ID, userId);
                preferenceEditor.putString(PREF_USER_NAME, userName);
                preferenceEditor.putString(PREF_DEVICE_ID, deviceID);
                preferenceEditor.putBoolean(PREF_APPLICATION_STATE, false);
                preferenceEditor.commit();
                // start main tab activity
                startActivity(intent);
                finish();
            } else {
                // notify users of failure, let users press back button to exit.
                Toast.makeText(getApplicationContext(), "Failed to register, please try again later",
                        Toast.LENGTH_SHORT).show();
            }
        }

    });

    builder.setNegativeButton(R.string.register_dialog_cancel, new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // exit out of this activity
            finish();
        }

    });

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

From source file:com.skubit.iab.fragments.TransactionsFragment.java

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

    TextView balanceLabel = (TextView) view.findViewById(R.id.wallet_balance_label);
    balanceLabel.setTypeface(FontManager.CONDENSED_REGULAR);

    TextView availableLabel = (TextView) view.findViewById(R.id.wallet_available_label);
    availableLabel.setTypeface(FontManager.CONDENSED_REGULAR);

    mBalance = (TextView) view.findViewById(R.id.wallet_balance);
    mAvailable = (TextView) view.findViewById(R.id.wallet_available);

    ListView list = (ListView) view.findViewById(R.id.list);
    list.setAdapter(mAdapter);/*from   ww w .j  a  va  2  s .co m*/

    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3) {
            TransactionDto transactionDto = (TransactionDto) adapter.getItemAtPosition(position);
            ObjectMapper mapper = new ObjectMapper();
            String value;
            try {
                value = mapper.writeValueAsString(transactionDto);
                startActivity(TransactionDetailsActivity.newIntent(value, getActivity().getPackageName()));
                getActivity().overridePendingTransition(R.anim.pull_in_right, R.anim.none);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }

    });

    mSwipe = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);

    mSwipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshBalance();
            getTransactions();
        }
    });

    return view;
}

From source file:app.hacked.ScheduleListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.schedule_list_fragment, null);
    progressBar = view.findViewById(R.id.progressBar);
    return view;//from w w  w  . j a  v  a  2  s  .com
}

From source file:com.irccloud.android.fragment.BufferOptionsFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();/*from w  w w .  ja  v  a  2  s .  c o m*/
    if (ctx == null)
        return null;
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_buffer_options, null);
    unread = (SwitchCompat) v.findViewById(R.id.unread);
    joinpart = (SwitchCompat) v.findViewById(R.id.joinpart);
    collapse = (SwitchCompat) v.findViewById(R.id.collapse);
    expandDisco = (SwitchCompat) v.findViewById(R.id.expandDisco);

    if (savedInstanceState != null && bid == -1 && savedInstanceState.containsKey("bid")) {
        bid = savedInstanceState.getInt("bid");
        cid = savedInstanceState.getInt("cid");
        type = savedInstanceState.getString("type");
    }

    if (type != null && type.equalsIgnoreCase("console")) {
        joinpart.setVisibility(View.GONE);
        collapse.setVisibility(View.GONE);
    } else {
        expandDisco.setVisibility(View.GONE);
    }

    return new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle("Display Options").setView(v).setPositiveButton("Save", new SaveClickListener())
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.codebutler.farebot.fragment.CardTripsFragment.java

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

    List<Trip> trips = new ArrayList<>();
    if (mTransitData.getTrips() != null && mTransitData.getTrips().length > 0) {
        for (Trip t : mTransitData.getTrips()) {
            trips.add(t);//from  w ww .  j  a va 2s.c om
        }
    }

    // This is for "legacy" implementations which have a separate list of refills.
    if (mTransitData.getRefills() != null && mTransitData.getRefills().length > 0) {
        for (Refill r : mTransitData.getRefills()) {
            trips.add(new RefillTrip(r));
        }
    }

    // Explicitly sort these events
    Collections.sort(trips, new Trip.Comparator());

    if (trips.size() > 0) {
        setListAdapter(new UseLogListAdapter(getActivity(), trips.toArray(new Trip[trips.size()])));
    } else {
        view.findViewById(android.R.id.list).setVisibility(View.GONE);
        view.findViewById(R.id.error_text).setVisibility(View.VISIBLE);
    }

    return view;
}

From source file:com.gmail.at.faint545.fragments.HistoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.remote_history, null);
    mPtrView = (PullToRefreshListView) view.findViewById(R.id.remote_history_ptr);
    loadingStub = (ViewStub) view.findViewById(R.id.loading);

    mPtrView.setOnRefreshListener(new OnRefreshListener() {
        @Override/*from   w  w w.  j  a  v  a2 s  . c  o  m*/
        public void onRefresh() {
            manualRefreshHistory(mPtrView);
        }
    });
    return view;
}

From source file:com.google.cast.samples.games.gamedebugger.PlayerTransitionDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.player_transition_dialog, null);
    mTransitionPlayerStateSection = (LinearLayout) view.findViewById(R.id.transition_player_state_section);
    mPlayerStateGroup = (RadioGroup) view.findViewById(R.id.radio_player_states);
    mExtraMessageDataLabel = (TextView) view.findViewById(R.id.extra_message_data_label);
    mExtraMessageDataEditText = (EditText) view.findViewById(R.id.extra_message_data);
    mCancelButton = (Button) view.findViewById(R.id.button_cancel);
    mOkButton = (Button) view.findViewById(R.id.button_ok);

    // Find the valid player states.
    GameManagerClient client = GameDebuggerApplication.getInstance().getCastConnectionManager()
            .getGameManagerClient();// w  w w.  j  a v a2 s .co  m
    GameManagerState state = client.getCurrentState();
    PlayerInfo player = state.getPlayer(getArguments().getString(KEY_PLAYER_ID));
    if (player == null) {
        return null;
    }
    if (player.isConnected()) {
        boolean defaultSelectionSet = false;
        for (int i = 0; i < PLAYER_STATES.length; i++) {
            if (PLAYER_STATES[i] != player.getPlayerState()) {
                RadioButton radioButton = new RadioButton(getActivity());
                radioButton.setText(getText(PLAYER_STATE_RESOURCE_IDS[i]));
                radioButton.setId(PLAYER_STATES[i]);
                radioButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
                mPlayerStateGroup.addView(radioButton);

                // Select the first element.
                if (!defaultSelectionSet) {
                    mPlayerStateGroup.check(PLAYER_STATES[i]);
                    defaultSelectionSet = true;
                }
            }
        }
    } else {
        RadioButton radioButton = new RadioButton(getActivity());
        radioButton.setText(getText(R.string.player_state_available));
        radioButton.setId(GameManagerClient.PLAYER_STATE_AVAILABLE);
        radioButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        mPlayerStateGroup.addView(radioButton);
        mPlayerStateGroup.check(GameManagerClient.PLAYER_STATE_AVAILABLE);
    }

    if (!getArguments().getBoolean(KEY_IS_TRANSITION)) {
        mTransitionPlayerStateSection.setVisibility(View.GONE);
        mExtraMessageDataLabel.setText(R.string.game_message_label);
        mExtraMessageDataEditText.setMinLines(4);
        mOkButton.setText(getText(R.string.button_send_game_message));

    }
    builder.setView(view);

    mCancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mOkButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onOkPressed();
        }
    });

    return builder.create();
}

From source file:com.smart.able2include.SimpleTextOverlayView.java

private void createView() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);/*from   ww  w. j av  a2s .c o  m*/

    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;
    params.y = 30;
    params.width = wm.getDefaultDisplay().getWidth();
    params.height = wm.getDefaultDisplay().getHeight() - 30;

    frameLayout = new RelativeLayout(mServiceContext);
    LayoutInflater layoutInflater = (LayoutInflater) mServiceContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout);

    TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText);
    text.setText(mSimpleText);
    dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            RemoveOvelay();
            delegate.onClick();
        }
    });
    synchronized (mSyncToken) {
        wm.addView(frameLayout, params);
        mOnTop = true;
    }
}