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:gov.wa.wsdot.android.wsdot.ui.MountainPassItemForecastFragment.java

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

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;/*from   w  w w  . j  a v  a 2s  .  c  o  m*/
}

From source file:at.alladin.rmbt.android.views.ResultDetailsView.java

/**
 * /*www. ja  v a 2  s  . c om*/
 * @param inflater
 * @return
 */
public View createView(final LayoutInflater inflater) {
    final View view = inflater.inflate(R.layout.test_result_detail, this);

    listView = (ListView) view.findViewById(R.id.valueList);
    listView.setVisibility(View.GONE);

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

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

    return view;
}

From source file:net.eledge.android.europeana.gui.dialog.NameInputDialog.java

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

    View view = inflater.inflate(R.layout.dialog_nameinput, null);
    TextView text = (TextView) view.findViewById(R.id.dialog_nameinput_textview);
    if (resText != -1) {
        text.setText(resText);/* w w w .ja v  a 2  s.c  o m*/
    } else {
        text.setVisibility(View.GONE);
    }
    mInput = (EditText) view.findViewById(R.id.dialog_nameinput_edittext);
    mInput.setHint(resInput);
    mInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //ignore
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //ignore
        }

        @Override
        public void afterTextChanged(Editable s) {
            mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(StringUtils.isNotBlank(s.toString()));
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    if (resTitle != -1) {
        builder.setTitle(resTitle);
    }
    builder.setPositiveButton(resPositiveButton, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String input = mInput.getText().toString();
            if (StringUtils.isNotBlank(input)) {
                mListener.positiveResponse(input);
                NameInputDialog.this.dismiss();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            mListener.negativeResponse();
            mDialog.dismiss();
        }
    });
    mDialog = builder.create();
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setCancelable(false);
    return mDialog;
}

From source file:com.f16gaming.pathofexilestatistics.PoeEntry.java

public AlertDialog getInfoDialog(Activity activity, Resources res) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.info, null);
    String nameFormat = res.getString(R.string.info_name);
    String accountFormat = res.getString(R.string.info_account);
    String rankFormat = res.getString(R.string.info_rank);
    String levelFormat = res.getString(R.string.info_level);
    String classFormat = res.getString(R.string.info_class);
    String experienceFormat = res.getString(R.string.info_experience);
    ((TextView) view.findViewById(R.id.info_name)).setText(String.format(nameFormat, name));
    ((TextView) view.findViewById(R.id.info_account)).setText(String.format(accountFormat, account));
    ((TextView) view.findViewById(R.id.info_rank)).setText(String.format(rankFormat, rank));
    ((TextView) view.findViewById(R.id.info_level)).setText(String.format(levelFormat, level));
    ((TextView) view.findViewById(R.id.info_class)).setText(String.format(classFormat, className));
    ((TextView) view.findViewById(R.id.info_experience)).setText(String.format(experienceFormat, experience));

    TextView status = (TextView) view.findViewById(R.id.info_status);
    status.setText(online ? R.string.online : R.string.offline);
    status.setTextColor(online ? res.getColor(R.color.online) : res.getColor(R.color.offline));

    builder.setTitle(R.string.info_title).setView(view).setPositiveButton(android.R.string.ok,
            new DialogInterface.OnClickListener() {
                @Override/*from  w  w w.java 2 s .com*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    return builder.create();
}

From source file:com.afwsamples.testdpc.safetynet.SafetyNetFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    BLACK = ContextCompat.getColor(getActivity(), R.color.text_black);
    DARK_RED = ContextCompat.getColor(getActivity(), R.color.dark_red);
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View rootView = inflater.inflate(R.layout.safety_net_attest_dialog, null);
    mMessageView = (TextView) rootView.findViewById(R.id.message_view);
    // Show scrollbar in textview.
    mMessageView.setMovementMethod(new ScrollingMovementMethod());
    return new AlertDialog.Builder(getActivity()).setView(rootView).setTitle(R.string.safetynet_dialog_title)
            .setNeutralButton(android.R.string.ok, null).create();
}

From source file:com.hybris.mobile.fragment.RegistrationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_register, null);
    view.findViewById(R.id.btnRegister).setOnClickListener(new OnClickListener() {

        @Override//from  www .j  a  v a2 s. co m
        public void onClick(View v) {
            validateAndSubmit();
        }
    });
    return view;
}

From source file:io.coldstart.android.TrapDetailListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Trap trap = listOfTraps.get(position);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    convertView = inflater.inflate(R.layout.trap_detail_list_item, null);

    String TrapDetails = "";

    /*try//w  w w. ja va2s .c  o m
    {
    JSONArray TrapJSON = new JSONArray(trap.trap);
            
    int trapsCount = TrapJSON.length();
            
    for(int i = 0; i < trapsCount; i++)
    {
        String tmpPayload = TrapJSON.getString(i);
            
        if(!tmpPayload.equals(""))
        {
            TrapDetails += tmpPayload + "\n\n";
        }
    }
    }
    catch (JSONException e)
    {
    TrapDetails = "Trap details failed to parse";
    }
            
            
    ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(TrapDetails);*/
    String trapDescription = "";
    try {
        trapDescription = trap.getPayloadAsString();
    } catch (Exception e) {
        trapDescription = "Unable to decode trap";
    }

    ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(trapDescription);

    ((TextView) convertView.findViewById(R.id.TrapDate))
            .setTypeface(Typeface.createFromAsset((context).getAssets(), "fonts/MavenPro-Regular.ttf"));
    ((TextView) convertView.findViewById(R.id.TrapDate)).setText(trap.date);

    if (trapOnClick != null) {
        convertView.setTag(position);
        convertView.setOnClickListener((OnClickListener) trapOnClick);
    }

    return convertView;
}

From source file:com.plusub.lib.example.activity.tab4.Tab4Fragment.java

@Override
protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    // TODO Auto-generated method stub
    return inflater.inflate(R.layout.fragment_tab_4, null);
}

From source file:com.handlerexploit.news.fragments.WeatherFragment.java

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

From source file:com.skubit.android.transactions.TransactionsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.wallet_transactions_fragment, null);
    TextView balanceLabel = (TextView) view.findViewById(R.id.wallet_balance_label);
    balanceLabel.setTypeface(FontManager.CONDENSED_REGULAR);

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

    ListView list = (ListView) view.findViewById(R.id.list);
    list.setAdapter(mAdapter);//from  www .  j  ava 2 s.c  o 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()));
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }

    });

    return view;
}