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.coodesoft.notee.DataAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    boolean isLastRow = position >= m_nItemsLoaded;
    int rowResID = isLastRow ? loadingRowResID : itemRowResID;
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(rowResID, parent, false);
    if (isLastRow) {
        if (position < m_nNoteAmount) {
            // Should there be more items loaded?
            int nextItemToLoad = position + PRELOAD_ITEMS;
            if (nextItemToLoad > m_nNoteAmount)
                nextItemToLoad = m_nNoteAmount;
            Log.d(LOG_TAG, "nextItemToLoad: " + nextItemToLoad);
            if (nextItemToLoad > m_nItemsLoaded) {
                Log.d(LOG_TAG, "itemsToLoad: " + nextItemToLoad);
                // Launch the loading thread if it is not currently running
                synchronized (loading) {
                    if (!loading.booleanValue()) {
                        Log.d(LOG_TAG, "Staring loading task");
                        loading = Boolean.TRUE;
                        m_threadLoading = new LoadingThread();
                        m_threadLoading.start();
                        Log.d(LOG_TAG, "Loading task started");
                    }//from  w ww  . j  a v  a 2  s .  c o m
                }
            }
        } else
            uiHandler.post(updateTask);
    } else {
        synchronized (m_lstNoteItems) {
            NoteItem item = m_lstNoteItems.get(position);
            // title
            TextView itemControl = (TextView) v.findViewById(R.id.note_item_title);
            itemControl.setText(item.m_strTitle);

            // set at
            TextView itemDate = (TextView) v.findViewById(R.id.note_item_subtitle);
            itemDate.setText(item.getSetAt());

            // icon
            ImageView imageView = (ImageView) v.findViewById(R.id.image_view_icon);
            if (item.isNote())
                imageView.setImageResource(R.drawable.ic_note);
            else
                imageView.setImageResource(R.drawable.ic_schedule);
        }
    }
    return v;
}

From source file:com.opemind.cartspage.client.android.book.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();/*from ww  w  .jav  a 2  s.c om*/
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:com.actionbarsherlock.internal.widget.ScrollingTabContainerView.java

public ScrollingTabContainerView(Context context) {
    super(context);
    setHorizontalScrollBarEnabled(false);

    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);//from w  w w .ja  v a  2 s.  c o m
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();

    mInflater = LayoutInflater.from(context);

    mTabLayout = createTabLayout();
    addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
}

From source file:com.zt.hackman.model.HackmanModel.java

/**
 * ??//from  www  .j  ava 2  s.c om
 */
private void initImage(RelativeLayout btn, String text) {
    View view = LayoutInflater.from(ac).inflate(R.layout.layout_front_one, btn, false);
    ImageView imageView = (ImageView) view.findViewById(R.id.layout_one_img);
    TextView textView = (TextView) view.findViewById(R.id.layout_one_text);
    if (textView == null) {
        textView.setVisibility(View.GONE);
    } else {
        textView.setText(text);
    }
    btn.addView(view);
}

From source file:com.door43.translationstudio.SettingsActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
    Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar_settings, root, false);
    root.addView(bar, 0); // insert at top
    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*from   w w  w.  j ava2s. c om*/
        public void onClick(View v) {
            finish();
        }
    });

    setupSimplePreferencesScreen();
}

From source file:com.cpyf.twelve.spies.qr.code.book.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();//from  w ww .  j av  a2s  .c o m
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java

/**
 * Unfortunately font-style must be set programmatically //
 * http://stackoverflow//from  ww  w  . j  a v a2 s. c  o m
 * .com/questions/10521416/option-menu-default-gray-border-removal <item
 * name="android:panelFullBackground">@color/barbackground</item>
 * 
 */
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    if (this instanceof AboutActivity) {
        return false;
    }

    MenuInflater inflater = getMenuInflater();
    if (this instanceof SignInActivity || this instanceof SignUpActivity
            || this instanceof ResetPasswordActivity) {
        inflater.inflate(R.menu.menusimple, menu);
    } else {
        inflater.inflate(R.menu.menu, menu);
    }

    getLayoutInflater().setFactory(new Factory() {
        public View onCreateView(String name, Context context, AttributeSet attrs) {
            if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {
                try {
                    LayoutInflater layoutInflater = LayoutInflater.from(context);
                    final View view = layoutInflater.createView(name, null, attrs);

                    new Handler().post(new Runnable() {
                        public void run() {
                            ((TextView) view).setTextColor(Color.WHITE);
                            view.setBackgroundResource(R.drawable.menu_selector);
                        }
                    });
                    return view;
                } catch (Exception e) {
                    Log.w("onCreateOptionsMenu", e.getMessage(), e);
                }
            }
            return null;
        }
    });
    return super.onCreateOptionsMenu(menu);
}

From source file:com.ruesga.rview.fragments.SnippetFragment.java

@Override
public void inflateContent(ViewGroup parent) {
    LayoutInflater li = LayoutInflater.from(getContext());
    mBinding = DataBindingUtil.inflate(li, R.layout.snippet_content, parent, true);

    mBinding.editor.setReadOnly(mReadOnly).setWrap(true).setTextSize(14).setNotifyMimeTypeChanges(!mReadOnly);
    if (!mReadOnly) {
        mBinding.editor.listenOn(mContentChangedListener);
    }/* w  w w.j a  v a2  s .  c  om*/
}

From source file:android_network.hetnet.vpn_service.AdapterLog.java

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    return LayoutInflater.from(context).inflate(R.layout.log, parent, false);
}

From source file:com.knurld.dropboxdemo.KnurldActivity.java

public void setKnurldEnrollment(View view) {
    Activity parent = (Activity) context;
    final View layoutView = LayoutInflater.from(parent).inflate(R.layout.knurld_setup, null);
    final PopupWindow loadingWindow = showLoadingPopup(layoutView);

    new Thread(new Runnable() {
        @Override//from  w w w.ja  v a 2  s  .c  o m
        public void run() {
            knurldService.startEnrollment();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    loadingWindow.dismiss();
                }
            });

        }
    }).start();
    showInstructions(layoutView);
}