下面列出了android.view.LayoutInflater#from ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
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));
}
@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);
}
}
@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;
}
public MRContentAdapter(Context context) {
super();
mInflater = LayoutInflater.from(context);
// mData = new ArrayList<MRContent>();
mSelectColor = Color.parseColor("#0662ad");
mData = DLNAController.getInstance(context).mData;
}
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());
}
@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));
}
}
@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);
}
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);
}
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();
}
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;
}
@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;
}
@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);
}
@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);
}
public ResultListAdapter(Context context, int layout, ArrayList<Result> arr) {
super(context, layout, arr);
mLayout = layout;
mResults = arr;
mInflater = LayoutInflater.from(context);
}
public SectionAdapter(Context c, ArrayList<String> groupList, ArrayList<ArrayList<String>> childList) {
super();
this.inflater = LayoutInflater.from(c);
this.groupList = groupList;
this.childList = childList;
}
public BindableAdapter(Context context) {
this.context = context;
this.inflater = LayoutInflater.from(context);
}
private void initComponents(Context context) {
this.inflater = LayoutInflater.from(context);
this.rotateAnimation = AnimationUtils.loadAnimation(context, R.anim.rotate_progress);
}
AdapterWrapper(Context context, RecyclerView.Adapter adapter) {
this.mInflater = LayoutInflater.from(context);
this.mAdapter = adapter;
}
/**
* 构造方法
*
* @param context Context
*/
public ApplistAdapter(Context context) {
this.mInflater = LayoutInflater.from(context);
}