Java Code Examples for android.view.LayoutInflater#from()

The following examples show how to use android.view.LayoutInflater#from() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Gojuon   File: ResultDialogHelper.java    License: MIT License 6 votes vote down vote up
private void init() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.fragment_result, null);

    builder.setCancelable(false)
            .setView(view)
            .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (mRunnable != null) mRunnable.run();
                }
            });

    mResultDialog = builder.create();
}
 
Example 2
public AppAdapter(@NonNull final Context context) {
	this.context = context;
	this.inflater = LayoutInflater.from(context);

	// get nRF installed app plugins from package manager
	final PackageManager pm = packageManager = context.getPackageManager();
	final Intent intent = new Intent(Intent.ACTION_MAIN);
	intent.addCategory(CATEGORY);

	final List<ResolveInfo> appList = applications = pm.queryIntentActivities(intent, 0);
	// TODO remove the following loop after some time, when there will be no more MCP 1.1 at the market.
	for (final ResolveInfo info : appList) {
		if (NRF_CONNECT_PACKAGE.equals(info.activityInfo.packageName)) {
			appList.remove(info);
			break;
		}
	}
	Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));
}
 
Example 3
@Override
public void onClick(View v) {
    llInit.setVisibility(View.GONE);
    llCollect.setVisibility(View.VISIBLE);
    llAdd.setVisibility(View.GONE);
    ibtnAddPub.setVisibility(View.VISIBLE);
    btnCollectFinish.setEnabled(false);
    pubs.clear();
    llPubs.removeAllViews();
    LayoutInflater inflater = LayoutInflater.from(AddEnterpriseHDMKeychainActivity.this);
    for (int i = 0;
         i < pubCount();
         i++) {
        inflater.inflate(R.layout.list_item_enterprise_hdm_collector, llPubs, true);
    }
}
 
Example 4
@Override
public View createNodeView(TreeNode node, ForumItemTree value) {
    final LayoutInflater inflater = LayoutInflater.from(context);
    final View view = inflater.inflate(R.layout.forum_item_default, null, false);
    title = (TextView) view.findViewById(R.id.forum_item_title);
    icon = (ImageView) view.findViewById(R.id.forum_item_icon);

    currentValue = value;
    title.setText(value.getTitle());

    icon.setImageDrawable(App.getVecDrawable(context, value.getForums() == null ? R.drawable.ic_forum_go_to_topics : (node.isExpanded() ? R.drawable.ic_expand_less_black_24dp : R.drawable.ic_expand_more_black_24dp)));

    if (value.getForums() == null) {
        int bg = App.getDrawableResAttr(context, R.attr.count_background);
        icon.setBackgroundResource(bg);
    } else {
        icon.setBackground(null);
    }

    return view;
}
 
Example 5
Source Project: NewsMe   File: MRContentAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public MRContentAdapter(Context context) {
    super();
    mInflater = LayoutInflater.from(context);
    // mData = new ArrayList<MRContent>();
    mSelectColor = Color.parseColor("#0662ad");
    mData = DLNAController.getInstance(context).mData;
}
 
Example 6
public StreamAdapter(Context context) {
	super(context, 0);
	
	final float density = context.getResources().getDisplayMetrics().density;
	mCornerRadius = (int) (CORNER_RADIUS * density + 0.5f);
	mMargin = (int) (MARGIN * density + 0.5f);

	mInflater = LayoutInflater.from(getContext());
}
 
Example 7
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
    switch (viewType){
        case TYPE_FAVORITE:
            return new FavoritesViewHolder(inflater.inflate(R.layout.cell_dashboard_favorites, viewGroup, false));
        default:
            return new AddToFavoritesViewHolder(inflater.inflate(R.layout.add_to_favorites_view, viewGroup, false));
    }
}
 
Example 8
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.parallax_scroll_expand_list_multiple_parallax);
	ParallaxExpandableListView listView = (ParallaxExpandableListView) findViewById(R.id.list_view);
	CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(LayoutInflater.from(this));
	listView.setAdapter(adapter);
}
 
Example 9
Source Project: SweetTips   File: SweetSnackbar.java    License: Apache License 2.0 5 votes vote down vote up
private SweetSnackbar(ViewGroup parent) {
    mTargetParent = parent;
    mContext = parent.getContext();

    ThemeUtils.checkAppCompatTheme(mContext);

    LayoutInflater inflater = LayoutInflater.from(mContext);
    mView = (SnackbarLayout) inflater.inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar, mTargetParent, false);

    mAccessibilityManager = (AccessibilityManager)
            mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example 10
public GroupGridViewAdapter(GroupGridViewActivity context, List<UserInfo> memberInfoList, boolean isCreator, int size) {
    this.mContext = context;
    mInflater = LayoutInflater.from(context);
    this.mMemberList = memberInfoList;
    this.mIsCreator = isCreator;
    this.mAvatarSize = size;
    mCurrentNum = mMemberList.size();

}
 
Example 11
DaysOfWeekPreferenceAdapterX(Context context, List<DayOfWeek> daysOfWeekList)
{
    this.daysOfWeekList = daysOfWeekList;

    // Cache the LayoutInflate to avoid asking for a new one each time.
    inflater = LayoutInflater.from(context);
    //this.context = context;
}
 
Example 12
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
   Context context = parent.getContext();
   LayoutInflater inflater = LayoutInflater.from(context);

   // Inflate the custom layout
   View contactView = inflater.inflate(R.layout.list_item, parent, false);

   contactView.setOnClickListener(itemClickListener);
   contactView.setOnLongClickListener(itemLongClickListener);

   // Return a new holder instance
   ViewHolder viewHolder = new ViewHolder(contactView);
   return viewHolder;
}
 
Example 13
Source Project: reacteu-app   File: SearchBookContentsActivity.java    License: MIT License 4 votes vote down vote up
@Override
 public void onCreate(Bundle icicle) {
   super.onCreate(icicle);

fakeR = new FakeR(this);

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

   Intent intent = getIntent();
   if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
     finish();
     return;
   }

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

   setContentView(fakeR.getId("layout", "search_book_contents"));
   queryTextView = (EditText) findViewById(fakeR.getId("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(fakeR.getId("id", "query_button"));
   queryButton.setOnClickListener(buttonListener);

   resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view"));
   LayoutInflater factory = LayoutInflater.from(this);
   headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"),
       resultListView, false);
   resultListView.addHeaderView(headerView);
 }
 
Example 14
@Override
public AbstractMessageListContentViewHolder getViewHolder(ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View v = inflater.inflate(R.layout.list_item_general_message, parent, false);
    return new FallbackMessageViewHolder(parent.getContext(), v, adamantAddressProcessor, avatar);
}
 
Example 15
public ResultListAdapter(Context context, int layout, ArrayList<Result> arr) {
    super(context, layout, arr);
    mLayout = layout;
    mResults = arr;
    mInflater = LayoutInflater.from(context);
}
 
Example 16
public SectionAdapter(Context c, ArrayList<String> groupList, ArrayList<ArrayList<String>> childList) {
	super();
	this.inflater = LayoutInflater.from(c);
	this.groupList = groupList;
	this.childList = childList;
}
 
Example 17
Source Project: RhythmSticks   File: BindableAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public BindableAdapter(Context context) {
  this.context = context;
  this.inflater = LayoutInflater.from(context);
}
 
Example 18
Source Project: YiBo   File: TweetProgressListAdapter.java    License: Apache License 2.0 4 votes vote down vote up
private void initComponents(Context context) {
	this.inflater = LayoutInflater.from(context);
	this.rotateAnimation = AnimationUtils.loadAnimation(context, R.anim.rotate_progress);
}
 
Example 19
AdapterWrapper(Context context, RecyclerView.Adapter adapter) {
    this.mInflater = LayoutInflater.from(context);
    this.mAdapter = adapter;
}
 
Example 20
Source Project: GPT   File: ListApkFragment.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 构造方法
 *
 * @param context Context
 */
public ApplistAdapter(Context context) {
    this.mInflater = LayoutInflater.from(context);
}