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:com.tassadar.multirommgr.installfragment.InstallCard.java

@Override
public View getCardContent(Context context) {
    m_view = LayoutInflater.from(context).inflate(R.layout.install_card, null);

    Resources res = m_view.getResources();

    CheckBox b = (CheckBox) m_view.findViewById(R.id.install_multirom);
    b.setText(res.getString(R.string.install_multirom, m_manifest.getMultiromVersion()));
    b.setChecked(m_manifest.hasMultiromUpdate());
    b.setOnCheckedChangeListener(this);

    b = (CheckBox) m_view.findViewById(R.id.install_recovery);
    if (m_manifest.getRecoveryFile() != null) {
        final Date rec_date = m_manifest.getRecoveryVersion();
        final String recovery_ver = Recovery.DISPLAY_FMT.format(rec_date);
        b.setText(res.getString(R.string.install_recovery, recovery_ver));
        b.setChecked(m_manifest.hasRecoveryUpdate());
        b.setOnCheckedChangeListener(this);

        // Force user to install recovery if not yet installed - it is needed to flash ZIPs
        if (m_manifest.hasRecoveryUpdate() && m_forceRecovery) {
            b.append(Html.fromHtml(res.getString(R.string.required)));
            b.setClickable(false);//from w w  w  . j  a  v a 2s. c o  m
        }
    } else {
        b.setChecked(false);
        b.setVisibility(View.GONE);
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
            android.R.layout.simple_spinner_dropdown_item);
    adapter.addAll(m_manifest.getKernels().keySet());
    Spinner s = (Spinner) m_view.findViewById(R.id.kernel_options);
    s.setAdapter(adapter);
    s.setEnabled(false);
    s.setSelection(getDefaultKernel());

    b = (CheckBox) m_view.findViewById(R.id.install_kernel);
    b.setOnCheckedChangeListener(this);
    b.setEnabled(!adapter.isEmpty());
    b.setChecked(!adapter.isEmpty() && m_manifest.hasKernelUpdate());

    Button install_btn = (Button) m_view.findViewById(R.id.install_btn);
    install_btn.setOnClickListener(this);

    ImageButton changelog_btn = (ImageButton) m_view.findViewById(R.id.changelog_btn);
    if (m_manifest.getChangelogs() == null || m_manifest.getChangelogs().length == 0)
        changelog_btn.setVisibility(View.GONE);
    else
        changelog_btn.setOnClickListener(this);

    if (m_savedState != null)
        restoreInstanceState();

    enableInstallBtn();
    return m_view;
}

From source file:com.commonsware.cwac.colormixer.ColorMixer.java

private void initMixer(AttributeSet attrs) {
    if (isInEditMode()) {
        return;/* ww w .ja v a  2  s  .c o m*/
    }

    LayoutInflater inflater = null;

    if (getContext() instanceof Activity) {
        inflater = ((Activity) getContext()).getLayoutInflater();
    } else {
        inflater = LayoutInflater.from(getContext());
    }

    inflater.inflate(R.layout.cwac_colormixer_main, this, true);

    swatch = findViewById(R.id.swatch);

    red = (SeekBar) findViewById(R.id.red);
    red.setMax(0xFF);
    red.setOnSeekBarChangeListener(onMix);

    green = (SeekBar) findViewById(R.id.green);
    green.setMax(0xFF);
    green.setOnSeekBarChangeListener(onMix);

    blue = (SeekBar) findViewById(R.id.blue);
    blue.setMax(0xFF);
    blue.setOnSeekBarChangeListener(onMix);

    if (attrs != null) {
        int[] styleable = R.styleable.ColorMixer;
        TypedArray a = getContext().obtainStyledAttributes(attrs, styleable, 0, 0);

        setColor(a.getInt(R.styleable.ColorMixer_cwac_colormixer_color, 0xFFA4C639));
        a.recycle();
    }
}

From source file:be.geecko.openlauncher.net.SuggestionsTask.java

@Override
protected void onPostExecute(JSONArray jsonResult) {
    super.onPostExecute(jsonResult);
    if (jsonResult == null)
        return;/* w  w  w. j  av  a 2s.co  m*/

    final int limit = jsonResult.length() > 3 ? 3 : jsonResult.length();
    final String[] results = new String[limit];
    try {
        for (int i = 0; i < limit; i++)
            results[i] = jsonResult.getString(i);
    } catch (JSONException e) {
        e.printStackTrace();
        return;
    }

    ListView resultList = (ListView) LayoutInflater.from(customContent.getContext())
            .inflate(R.layout.suggestion_listview, null);
    resultList.setAdapter(
            new ArrayAdapter<CharSequence>(customContent.getContext(), R.layout.card_list_adapter, results));
    resultList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            CustomContent.search(results[i], view.getContext());
        }
    });

    if (((EditText) customContent.findViewById(R.id.search_bar)).getText().length() > 0)
        customContent.pushCard(resultList, SuggestionsCard.class);
}

From source file:com.grarak.kerneladiutor.views.AdNativeExpress.java

public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override/*from www .ja  va 2s .com*/
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext()
            .getString(Utils.DARK_THEME ? R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}

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.github.rutvijkumar.twittfuse.adapters.UserArrayAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    final User user = getItem(position);
    // Check if an existing view is being reused, otherwise inflate the view

    ViewHolder viewHolder; // view lookup cache stored in tag
    if (convertView == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(getContext());
        convertView = inflater.inflate(R.layout.user_item, parent, false);

        viewHolder.name = (TextView) convertView.findViewById(R.id.tv_username);
        viewHolder.screenName = (TextView) convertView.findViewById(R.id.tv_screenname);
        viewHolder.userBio = (TextView) convertView.findViewById(R.id.tv_userBio);
        viewHolder.userProfilePic = (ImageView) convertView.findViewById(R.id.img_profilepic);

        viewHolder.followAction = (ImageButton) convertView.findViewById(R.id.tvFollow);

        convertView.setTag(viewHolder);/*from   ww  w.  j ava2 s . c o  m*/
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }
    // Populate the data into the template view using the data object

    viewHolder.userProfilePic.setImageResource(android.R.color.transparent);
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage(user.getProfileImageUrl(), viewHolder.userProfilePic);

    viewHolder.name.setText(user.getName());
    viewHolder.screenName.setText("@" + user.getScreenName());
    viewHolder.userProfilePic.setTag(user);
    viewHolder.userBio.setText(user.getDescription());

    if (!user.isFollowing()) {
        viewHolder.followAction.setVisibility(View.VISIBLE);
        final ImageButton imgBtn = viewHolder.followAction;
        viewHolder.followAction.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                client.followUser(user.getScreenName(), new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(JSONObject arg0) {
                        imgBtn.setVisibility(View.INVISIBLE);
                    }
                });

            }
        });
    } else {
        viewHolder.followAction.setVisibility(View.INVISIBLE);
    }

    //pullToRefreshListView setOnItem click listerner is not working because of auto link
    convertView.setOnClickListener(new UserOnClickListener(user));
    viewHolder.userProfilePic.setOnClickListener(new UserOnClickListener(user));

    return convertView;
}

From source file:com.df.app.carCheck.VehicleInfoLayout.java

private void init(Context context) {
    rootView = LayoutInflater.from(context).inflate(R.layout.vehicle_info_layout, this);

    vehicleModel = MainActivity.vehicleModel;
    mCarSettings = CarSettings.getInstance();

    // ?// ww  w . ja va 2  s.c o m
    Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button);
    brandSelectButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            selectCarManually();
        }
    });
}

From source file:android.example.com.animationdemos.LayoutChangesActivity.java

private void addItem() {
    // Instantiate a new "row" view.
    final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example,
            mContainerView, false);/*from w  w w  . j ava 2s  .  c o  m*/
    // Set the text in the new row to a random country.
    ((TextView) newView.findViewById(android.R.id.text1))
            .setText(COUNTRIES[(int) (Math.random() * COUNTRIES.length)]);
    // Set a click listener for the "X" button in the row that will remove the row.
    newView.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Remove the row from its parent (the container view).
            // Because mContainerView has android:animateLayoutChanges set to true,
            // this removal is automatically animated.
            mContainerView.removeView(newView);
            // If there are no rows remaining, show the empty view.
            if (mContainerView.getChildCount() == 0) {
                findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
            }
        }
    });
    // Because mContainerView has android:animateLayoutChanges set to true,
    // adding this view is automatically animated.
    mContainerView.addView(newView, 0);
}

From source file:com.df.kia.carCheck.VehicleInfoLayout.java

private void init(Context context) {
    rootView = LayoutInflater.from(context).inflate(R.layout.vehicle_info_layout, this);

    vehicleModel = MainActivity.vehicleModel;
    mCarSettings = BasicInfoLayout.mCarSettings;

    // ?/* ww  w.j  a  va2  s.com*/
    Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button);
    brandSelectButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            selectCarManually();
        }
    });
}

From source file:net.naonedbus.card.impl.TraficCard.java

@Override
public void onLoadFinished(final Loader<List<InfoTrafic>> loader, final List<InfoTrafic> infoTrafics) {

    if (infoTrafics == null || infoTrafics.isEmpty()) {
        showMessage(R.string.msg_nothing_info_trafic, R.drawable.ic_checkmark_holo_light);
    } else {/*from   www. j av  a 2 s  .c  o  m*/
        final LayoutInflater inflater = LayoutInflater.from(getContext());

        mRoot.removeAllViews();
        for (final InfoTrafic infoTrafic : infoTrafics) {
            mRoot.addView(createView(inflater, mRoot, infoTrafic));
        }

        showContent();
    }

}