List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:com.kaixin.android.service.UpdateApp.java
public void Beginning() { LinearLayout ll = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.layout_progress, null); mProgressBar = (ProgressBar) ll.findViewById(R.id.down_pb); mDownloadTxt = (TextView) ll.findViewById(R.id.download_txt); Builder builder = new Builder(context); builder.setView(ll);// www. jav a 2s . co m builder.setTitle(context.getString(R.string.update_load_txt)); builder.setNegativeButton(context.getString(R.string.update_hide_txt), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(context, UpdateService.class); context.startService(intent); dialog.dismiss(); } }); builder.show(); new Thread() { public void run() { loadFile(DOWNLOAD_URL); } }.start(); }
From source file:com.fullteem.yueba.app.adapter.MessageAdapter.java
public MessageAdapter(Context context, String username, String ImageUrl, int chatType) { this.username = username; this.context = context; this.ImageUrl = ImageUrl; inflater = LayoutInflater.from(context); activity = (Activity) context;/* ww w . ja v a 2s .c o m*/ appContext = AppContext.getApplication(); this.conversation = EMChatManager.getInstance().getConversation(username); }
From source file:com.grarak.romswitcher.Utils.Utils.java
public static void setupPassword(final Context context) { LayoutInflater factory = LayoutInflater.from(context); final View btn = factory.inflate(R.layout.password, null); mOldPasstext = (TextView) btn.findViewById(R.id.oldpass_text); mOldPassword = (EditText) btn.findViewById(R.id.oldpass); mNewPassword = (EditText) btn.findViewById(R.id.newpass); mConfirmPassword = (EditText) btn.findViewById(R.id.confirmpass); if (!mPassfile.exists()) { mOldPassword.setVisibility(View.GONE); mOldPasstext.setVisibility(View.GONE); }//from w w w . java 2s .c om Builder builder = new Builder(context); builder.setView(btn).setTitle(context.getString(R.string.setuppass)) .setNegativeButton(context.getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { checkOldPass(context); } }).show(); }
From source file:com.fastbootmobile.encore.app.adapters.PlaylistListAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == VIEW_TYPE_REGULAR) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View root = inflater.inflate(R.layout.item_playlist_list, parent, false); ensureOrderer(parent.getContext()); return new ViewHolder(root); } else if (viewType == VIEW_TYPE_HEADER) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View root = inflater.inflate(R.layout.item_special_playlists, parent, false); ensureOrderer(parent.getContext()); return new SpecialViewHolder(root); }/*from w w w .j av a 2 s . c om*/ return null; // Should not happen }
From source file:com.odoo.base.addons.mail.widget.MailChatterCompose.java
private void addAttachment(OValues values) { View attachmentView = LayoutInflater.from(this).inflate(R.layout.base_attachment_item, horizontalScrollView, false);/*from w w w . ja v a 2s .c om*/ String fileName = values.getString("name"); String type = values.getString("file_type"); ImageView imgPreview = (ImageView) attachmentView.findViewById(R.id.attachmentPreview); if (type.contains("image")) { OLog.log(values.getString("file_uri")); imgPreview.setImageURI(Uri.parse(values.getString("file_uri"))); } else if (type.contains("audio")) { imgPreview.setImageResource(R.drawable.audio); } else if (type.contains("video")) { imgPreview.setImageResource(R.drawable.video); } else { imgPreview.setImageResource(R.drawable.file); } OControls.setText(attachmentView, R.id.attachmentFileName, fileName); attachmentView.setTag(values); attachmentView.findViewById(R.id.btnRemoveAttachment).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { horizontalScrollView.removeView((View) v.getParent()); } }); horizontalScrollView.addView(attachmentView); }
From source file:com.justone.android.main.MainActivity.java
@SuppressWarnings("deprecation") @Override/* w w w . j av a2s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentContext = this; //listviewview this.viewMap = new HashMap<String, ListViewAdapter>(); // this.asynImageLoader = JustOne.getAsynImageLoader(); this.dataOp = JustOne.getDataOp(); // this.res = getResources(); // Resource object to get Drawables // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); justOne = (JustOne) getApplication(); justOne.pushActivity(this); // view LayoutInflater inflater = LayoutInflater.from(this); //details_page_setitem = inflater.inflate(R.layout.one_details_page_setitem, null); main_item = inflater.inflate(R.layout.activity_main, null); bind_item = inflater.inflate(R.layout.one_details_page_binditem, null); about_one = inflater.inflate(R.layout.about_one, null); //microblog = inflater.inflate(R.layout.one_details_page_microblog, null); feedback = inflater.inflate(R.layout.feedback, null); setContentView(main_item); initData(); // view mListView = (ListView) findViewById(R.id.tab2); //ArrayList<ArrayList<String>> list_data = loadData("list",data); listAdapter = new ListViewAdapter(this, mList, mGist, R.id.scrollview, R.layout.list_item); mListView.setAdapter(listAdapter); /* mListView1 = (ListView) findViewById(R.id.tab1); //ArrayList<ArrayList<String>> collect_data = loadData("collect",data); collectAdapter = new ListViewAdapter(this,mList, mGist, R.id.collectScrollview, R.layout.collect_item); mListView1.setAdapter(collectAdapter); */ homeListView = (ListView) findViewById(R.id.homeTab); homeAdapter = new ListViewAdapter(this, mList, mGist, R.id.homeScrollView, R.layout.home_item); homeListView.setAdapter(homeAdapter); qaListView = (ListView) findViewById(R.id.QAtab); //ArrayList<ArrayList<String>> QA_data = loadData("QA",data); QAAdapter = new ListViewAdapter(this, mList, mGist, R.id.qaScrollView, R.layout.qa_item); qaListView.setAdapter(QAAdapter); //detailView = (ListView) findViewById(R.id.tab3); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); //detailAdapter = new ListViewAdapter(this, // mList, mGist, // R.id.detailScrollView, R.layout.detail_item); //detailView.setAdapter(detailAdapter); /*//loading list view loadingView = (ListView) findViewById(R.id.loading_view); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); loadingAdapter = new ListViewAdapter(this, mList, mGist, R.id.loadingScrollView, R.layout.one_welcome_ad); loadingView.setAdapter(loadingAdapter); */ tabs = (TabHost) findViewById(R.id.tabhost); tabWidget = (TabWidget) findViewById(android.R.id.tabs); int width = 100; int height = 100; tabs.setup(); tabs.addTab(tabs.newTabSpec("home tab").setIndicator("", this.res.getDrawable(R.drawable.home_tab_selector)) .setContent(R.id.homeTab)); tabs.addTab(tabs.newTabSpec("list tab").setIndicator("", this.res.getDrawable(R.drawable.one_tab_selector)) .setContent(R.id.tab2)); tabs.addTab(tabs.newTabSpec("QA Tab").setIndicator("", this.res.getDrawable(R.drawable.qa_tab_selector)) .setContent(R.id.QAtab)); /* tabs.addTab(tabs.newTabSpec("second tab").setIndicator("", null) .setContent(R.id.tab1));*/ //tabs.addTab(tabs.newTabSpec("second tab").setIndicator("",this.res.getDrawable(R.drawable.more_tab_selector)) // .setContent(R.id.tab3)); tabs.setCurrentTab(0); for (int i = 0; i < tabWidget.getChildCount(); i++) { /** * fill_parent */ tabWidget.getChildAt(i).getLayoutParams().height = height; tabWidget.getChildAt(i).getLayoutParams().width = width; /** * tab */ final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(this.getResources().getColorStateList(android.R.color.white)); tv.setTextSize(15); tv.setGravity(Gravity.TOP); } mActivityName = getString(R.string.activity_c_label); mStatusTracker.setStatus(mActivityName, getString(R.string.on_create)); Utils.printStatus(mStatusView, mStatusAllView); detector = new GestureDetector(this); viewMap.put("home", this.homeAdapter); // View returnBackToIndex = main_item.findViewById(R.id.returnBackToIndex_layout); returnBackToIndex.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { MainActivity.this.finish(); // TODO Auto-generated method stub } }); userFirstTips(); }
From source file:com.vk.sdk.dialogs.VKShareDialog.java
@NonNull @Override/*from ww w . java 2 s. c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null); assert mInternalView != null; mSendButton = (Button) mInternalView.findViewById(R.id.sendButton); mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress); mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer); mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText); mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView); LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout); mSendButton.setOnClickListener(sendButtonPress); //Attachment text if (savedInstanceState != null) { mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY)); mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY); mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY); mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY); } else if (mAttachmentText != null) { mShareTextField.setText(mAttachmentText); } //Attachment photos mPhotoLayout.removeAllViews(); if (mAttachmentImages != null) { for (VKUploadImage mAttachmentImage : mAttachmentImages) { addBitmapToPreview(mAttachmentImage.mImageData); } mPhotoLayout.setVisibility(View.VISIBLE); } if (mExistingPhotos != null) { processExistingPhotos(); } if (mExistingPhotos == null && mAttachmentImages == null) { mPhotoLayout.setVisibility(View.GONE); } //Attachment link if (mAttachmentLink != null) { TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle), linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost); linkTitle.setText(mAttachmentLink.linkTitle); linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl)); mAttachmentLinkLayout.setVisibility(View.VISIBLE); } else { mAttachmentLinkLayout.setVisibility(View.GONE); } Dialog result = new Dialog(context); result.requestWindowFeature(Window.FEATURE_NO_TITLE); result.setContentView(mInternalView); result.setCancelable(true); result.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { if (mListener != null) { mListener.onVkShareCancel(); } VKShareDialog.this.dismiss(); } }); return result; }
From source file:android.support.v7.internal.widget.ActionBarContextView.java
private void initTitle() { if (mTitleLayout == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.abc_action_bar_title_item, this); mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1); mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title); mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle); if (mTitleStyleRes != 0) { mTitleView.setTextAppearance(getContext(), mTitleStyleRes); }/*from w w w . j a va2 s. co m*/ if (mSubtitleStyleRes != 0) { mSubtitleView.setTextAppearance(getContext(), mSubtitleStyleRes); } } mTitleView.setText(mTitle); mSubtitleView.setText(mSubtitle); final boolean hasTitle = !TextUtils.isEmpty(mTitle); final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle); mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE); mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE); if (mTitleLayout.getParent() == null) { addView(mTitleLayout); } }
From source file:be.digitalia.fosdem.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;//from w w w. j a v a 2 s. co m TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { tabView.setSelected(true); } } }
From source file:com.cssweb.android.quote.QuoteDetail.java
/** * /* w w w . j a va2 s. com*/ * @param jArr * @param table * @param zrsp * @throws JSONException */ private void appendRow(JSONArray jArr, TableLayout table, double zrsp) throws JSONException { table.setStretchAllColumns(true); table.removeAllViews(); if ("cf".equals(exchange.toLowerCase()) || "dc".equals(exchange.toLowerCase()) || "sf".equals(exchange.toLowerCase()) || "cz".equals(exchange.toLowerCase())) { int len = jArr.length(); int color = Utils.getTextColor(mContext, 0); for (int i = 0; i < len; i++) { LinearLayout linearLayout = (LinearLayout) findViewById(R.id.title23); linearLayout.setVisibility(View.VISIBLE); JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3); TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4); TextView t5 = (TextView) row.findViewById(R.id.zr_table_col5); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); double cjsl = Arith.round(jA.getDouble(1), 0); t3.setText(Utils.dataFormation(cjsl, 0)); t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); t4.setText(jA.getString(7)); t5.setText(jA.getString(8)); table.addView(row); if ("B".equals(jA.getString(6))) { color = Utils.getTextColor(mContext, 3); t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } else if ("S".equals(jA.getString(6))) { color = Utils.getTextColor(mContext, 4); t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } else { t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } } } else { if (stocktype.charAt(0) == '0') {// //for (int i = jArr.length()-1; i >= 0; i--) { for (int i = 0; i <= jArr.length() - 1; i++) { JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3); TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); double cjsl = Arith.round(jA.getDouble(1), 0); t3.setText(Utils.dataFormation(cjsl, 0)); if (cjsl > 500) t3.setTextColor(Utils.getTextColor(mContext, 6)); else t3.setTextColor(Utils.getTextColor(mContext, 1)); t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); t4.setText(jA.getString(6)); if ("B".equals(jA.getString(6))) t4.setTextColor(Utils.getTextColor(mContext, 3)); else t4.setTextColor(Utils.getTextColor(mContext, 4)); table.addView(row); } //? int num = jArr.length(); if (num < 16) { while (num < 16) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); table.addView(row); num++; } } } else if (stocktype.charAt(0) == '1' || stocktype.charAt(0) == '2') {// //for (int i = jArr.length()-1; i >= 0; i--) { for (int i = 0; i <= jArr.length() - 1; i++) { JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col4); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t3.setText(Utils.getAmountFormat(jA.getDouble(5), true)); t3.setTextColor(Utils.getTextColor(mContext, 1)); table.addView(row); } //? int num = jArr.length(); if (num < 16) { while (num < 16) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); table.addView(row); num++; } } } } }