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, boolean attachToRoot) 

Source Link

Document

Inflate a new view hierarchy from the specified XML node.

Usage

From source file:com.ronnyml.sweetplayer.fragments.CommonFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_common, container, false);
    mActivity = this.getActivity();
    mImageLoader = MyImageLoader.getInstance(mActivity).getImageLoader();
    mImageView = (RoundedNetworkImageView) rootView.findViewById(R.id.playlist_image);
    mLoadingBar = (ProgressBar) rootView.findViewById(R.id.loading_bar);
    mSongsListview = (ObservableListView) rootView.findViewById(R.id.songs_listview);
    mTopArtistsLayout = (LinearLayout) rootView.findViewById(R.id.top_artists_layout);
    mTopSongsLayout = (LinearLayout) rootView.findViewById(R.id.top_songs_layout);

    mSongsListview.setScrollViewCallbacks(this);
    if (Utils.isConnectedToInternet(mActivity)) {
        getCommonData();//from  w w  w .  j  a v a 2  s .c o  m
    } else {
        Utils.showAlertDialog(mActivity, mActivity.getString(R.string.internet_no_connection_title),
                mActivity.getString(R.string.internet_no_connection_message));
    }

    return rootView;
}

From source file:at.alladin.rmbt.android.sync.RMBTSyncEnterCodeFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    view = inflater.inflate(R.layout.sync_enter_code, container, false);

    syncButton = (Button) view.findViewById(R.id.button);

    overlay = (LinearLayout) view.findViewById(R.id.overlay);

    codeField = (EditText) view.findViewById(R.id.code);

    final RMBTSyncEnterCodeFragment tmp = this;

    listener = new OnClickListener() {
        @Override/*from  w ww .  jav a2 s  .co  m*/
        public void onClick(final View v) {

            final String syncCode = codeField.getText().toString().toUpperCase(Locale.US);

            if (syncCode.length() == 12) {
                if (syncTask == null || syncTask != null || syncTask.isCancelled()) {
                    overlay.setVisibility(View.VISIBLE);
                    overlay.setClickable(true);
                    overlay.bringToFront();

                    syncButton.setOnClickListener(null);
                    // codeField.setClickable(false);

                    syncTask = new CheckSyncTask(getActivity());

                    syncTask.setEndTaskListener(tmp);
                    syncTask.execute(syncCode);
                }
            } else
                codeField.setError(getActivity().getString(R.string.sync_enter_code_length));
        }
    };

    codeField.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
            listener.onClick(v);
            return true;
        }
    });

    syncButton.setOnClickListener(listener);

    return view;
}

From source file:com.hybris.mobile.app.commerce.adapter.OrderHistoryAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View rowView;// w  w w.  ja  va 2 s .  c om

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_order_history, parent, false);
        rowView.setTag(new OrderHistoryViewHolder(rowView, position));
    } else {
        rowView = convertView;
    }

    OrderHistoryViewHolder orderHistoryViewHolder = (OrderHistoryViewHolder) rowView.getTag();

    final OrderHistory order = getItem(position);

    if (order != null) {
        // Order Code
        if (StringUtils.isNotBlank(order.getCode())) {
            orderHistoryViewHolder.orderNumberTextView.setText(order.getCode());
        }

        // Date placed / created
        if (order.getPlaced() != null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DATE_FORMAT_COMPLETE,
                    SimpleDateFormat.getAvailableLocales()[0]);

            orderHistoryViewHolder.orderDatePlacedTextView.setText(simpleDateFormat.format(order.getPlaced()));
        }

        // Status

        if (StringUtils.isNotBlank(order.getStatusDisplay())) {
            orderHistoryViewHolder.orderStatusTextView.setText(order.getStatusDisplay());
        }

        // Total price
        if (order.getTotal() != null) {
            orderHistoryViewHolder.orderTotalTextView.setText(order.getTotal().getFormattedValue());
        }

        // Redirecting to the order detail page when clicking on the item
        orderHistoryViewHolder.orderHistoryLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentOrderDetail = new Intent(getContext(), OrderDetailActivity.class);
                intentOrderDetail.putExtra(IntentConstants.ORDER_CODE, order.getCode());
                getContext().startActivity(intentOrderDetail);
            }
        });

    }
    return rowView;
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.ExtraProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_extra_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    final String[] methods = { "GET", "POST", "PUT", "DELETE" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item);
    for (int i = 0; i < methods.length; i++) {
        adapter.add(methods[i]);/*w  ww  .j  av  a 2  s  .c  o  m*/
    }
    Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
    spinner.setAdapter(adapter);

    Button sendButton = (Button) view.findViewById(R.id.fragment_extra_send);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            onClickSend(view);
        }
    });

    return view;
}

From source file:com.mercandalli.android.apps.files.user.community.TalkFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_user, container, false);
    mCircularProgressBar = (ProgressBar) mRootView.findViewById(R.id.circularProgressBar);
    mMessageTextView = (TextView) mRootView.findViewById(R.id.message);

    mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    final RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setItemAnimator(/*new SlideInFromLeftItemAnimator(mRecyclerView)*/new DefaultItemAnimator());
    mRecyclerView/*from  w  w w  .j  a v  a  2s .com*/
            .addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

    mRootView.findViewById(R.id.circle).setVisibility(View.GONE);

    mSwipeRefreshLayout = (SwipeRefreshLayout) mRootView.findViewById(R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshList();
        }
    });

    refreshList();

    return mRootView;
}

From source file:de.kirchnerei.bicycle.battery.BatteryListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_battery_list, container, false);
}

From source file:com.chaosinmotion.securechat.fragments.ChangePasswordStart.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_change_password_start, container, false);
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.ProximityProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View view = inflater.inflate(R.layout.fragment_proximity_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    final Switch proximity = (Switch) view.findViewById(R.id.fragment_proximity_ondevice);
    proximity.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override//from w w w  .  jav a 2 s. co m
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            if (isChecked) {
                registerEvent();
            } else {
                unregisterEvent();
            }
        }
    });

    return view;
}

From source file:at.bitfire.davdroid.ui.setup.LoginCredentialsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.login_credentials_fragment, container, false);

    radioUseEmail = (RadioButton) v.findViewById(R.id.login_type_email);
    emailDetails = (LinearLayout) v.findViewById(R.id.login_type_email_details);
    editEmailAddress = (EditText) v.findViewById(R.id.email_address);
    editEmailPassword = (EditPassword) v.findViewById(R.id.email_password);

    radioUseURL = (RadioButton) v.findViewById(R.id.login_type_url);
    urlDetails = (LinearLayout) v.findViewById(R.id.login_type_url_details);
    editBaseURL = (EditText) v.findViewById(R.id.base_url);
    editUserName = (EditText) v.findViewById(R.id.user_name);
    editUrlPassword = (EditPassword) v.findViewById(R.id.url_password);

    radioUseEmail.setOnCheckedChangeListener(this);
    radioUseURL.setOnCheckedChangeListener(this);

    if (savedInstanceState == null) {
        // first call

        Activity activity = getActivity();
        Intent intent = (activity != null) ? activity.getIntent() : null;
        if (intent != null) {
            // we've got initial login data
            String url = intent.getStringExtra(LoginActivity.EXTRA_URL),
                    username = intent.getStringExtra(LoginActivity.EXTRA_USERNAME),
                    password = intent.getStringExtra(LoginActivity.EXTRA_PASSWORD);

            if (url != null) {
                radioUseURL.setChecked(true);
                editBaseURL.setText(url);
                editUserName.setText(username);
                editUrlPassword.setText(password);
            } else {
                radioUseEmail.setChecked(true);
                editEmailAddress.setText(username);
                editEmailPassword.setText(password);
            }//  w  w w. ja v  a 2  s  .  c om

        } else
            radioUseEmail.setChecked(true);
    }

    final Button login = (Button) v.findViewById(R.id.login);
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LoginCredentials credentials = validateLoginData();
            if (credentials != null)
                DetectConfigurationFragment.newInstance(credentials).show(getFragmentManager(), null);
        }
    });

    return v;
}

From source file:com.eutectoid.dosomething.usersettings.UserSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.usersettings_fragment, container, false);
    loginButton = (LoginButton) view.findViewById(R.id.usersettings_fragment_login_button);
    loginButton.setFragment(this);

    connectedStateLabel = (TextView) view.findViewById(R.id.usersettings_fragment_profile_name);

    // if no background is set for some reason, then default to Facebook blue
    if (view.getBackground() == null) {
        view.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
    } else {//from  ww  w  . j a  va 2s .c  om
        view.getBackground().setDither(true);
    }
    return view;
}