List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:app.daeng.tokped.Utils.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w . j a va 2s . c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } // First spacer tab TextView firstTab = new TextView(getContext()); mTabStrip.addView(firstTab, 0); // Last spacer tab TextView lastTab = new TextView(getContext()); mTabStrip.addView(lastTab); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
public void openDialog() { // get prompts.xml view LayoutInflater li = LayoutInflater.from(GetAllVehicalDetails.this); View promptsView = li.inflate(R.layout.prompt, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(GetAllVehicalDetails.this); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); alertDialogBuilder.setTitle("Why you want to stop this"); final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to result // edit text //result.setText(userInput.getText()); if (!userInput.getText().toString().trim().isEmpty()) { reason = userInput.getText().toString().trim(); getUserData(reason);/* w w w .ja v a2s.c om*/ } else { Toast.makeText(GetAllVehicalDetails.this, "Please fill your reason", Toast.LENGTH_LONG).show(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); }
From source file:agilec.ikeaswipe.utils.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w ww. ja v a2s . c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); // Added LinearLayout to evenly space the tabs with icons LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f); tabView.setLayoutParams(lp); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.netease.qa.emmagee.service.EmmageeService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(LOG_TAG, "service onStart"); PendingIntent contentIntent = PendingIntent.getActivity(getBaseContext(), 0, new Intent(this, MainPageActivity.class), 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon).setWhen(System.currentTimeMillis()) .setAutoCancel(true).setContentTitle("ETest"); startForeground(startId, builder.build()); HttpUtils.testSuitId = 0;//from www . j a v a2 s . co m pid = intent.getExtras().getInt("pid"); uid = intent.getExtras().getInt("uid"); processName = intent.getExtras().getString("processName"); packageName = intent.getExtras().getString("packageName"); startActivity = intent.getExtras().getString("startActivity"); appVersion = intent.getExtras().getString("appVersion"); cpuInfo = new CpuInfo(getBaseContext(), pid, Integer.toString(uid)); readSettingInfo(); if (isFloating) { viFloatingWindow = LayoutInflater.from(this).inflate(R.layout.floating, null); txtUnusedMem = (TextView) viFloatingWindow.findViewById(R.id.memunused); txtTotalMem = (TextView) viFloatingWindow.findViewById(R.id.memtotal); txtTraffic = (TextView) viFloatingWindow.findViewById(R.id.traffic); btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi); wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (wifiManager.isWifiEnabled()) { btnWifi.setText(R.string.close_wifi); } else { btnWifi.setText(R.string.open_wifi); } txtUnusedMem.setText(getString(R.string.calculating)); txtUnusedMem.setTextColor(android.graphics.Color.RED); txtTotalMem.setTextColor(android.graphics.Color.RED); txtTraffic.setTextColor(android.graphics.Color.RED); btnStop = (Button) viFloatingWindow.findViewById(R.id.stop); btnStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("isServiceStop", true); intent.setAction(SERVICE_ACTION); sendBroadcast(intent); stopSelf(); } }); createFloatingWindow(); } createResultCsv(); if (isRoot) { getlog(); } handler.postDelayed(task, 1000); return START_NOT_STICKY; }
From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java
private void toggleUpdatingState() { mIsUpdating = !mIsUpdating;//from ww w.j ava 2s. c o m ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); bar.setDisplayShowHomeEnabled(!mIsUpdating); bar.setDisplayShowTitleEnabled(!mIsUpdating); bar.setDisplayShowCustomEnabled(mIsUpdating); EventBus.getDefault().post(new ProgressBarToggleEvent(mIsUpdating)); if (mIsUpdating) { View mLogoView = LayoutInflater.from(getActivity()).inflate(R.layout.updating_actionbar_layout, null); bar.setCustomView(mLogoView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLogoView.clearAnimation(); mLogoView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.ab_custom_view_anim)); } getActivity().supportInvalidateOptionsMenu(); }
From source file:acn.android.framework.view.helper.SlidingTabLayout.java
private void populateTabStrip(float tabTitleSize, ColorStateList textColorStateList) { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w .j a va 2 s . c o m*/ AcnTextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (AcnTextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && AcnTextView.class.isInstance(tabView)) { tabTitleView = (AcnTextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); ////////TAB CUSTOMIZATIONS/////// if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setHorizontalFadingEdgeEnabled(true); if (!TextUtils.isEmpty(Config.appFont)) tabTitleView .setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/" + Config.appFont)); tabTitleView.setTextColor(textColorStateList); tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTitleSize); /*WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int widthInPx = Math.min(display.getHeight(), display.getWidth()); //ACCORDING TO MINIMUM WIDTH-ED SIDE tabTitleView.setLayoutParams(new LinearLayout.LayoutParams(widthInPx / 3, LayoutParams.WRAP_CONTENT));*/ ///////////////////////////////// mTabStrip.addView(tabView); } }
From source file:android.support.v7.preference.PreferenceDialogFragmentCompat.java
/** * Creates the content view for the dialog (if a custom content view is * required). By default, it inflates the dialog layout resource if it is * set./*from w ww . j a v a2s . c om*/ * * @return The content View for the dialog. * @see DialogPreference#setLayoutResource(int) */ protected View onCreateDialogView(Context context) { final int resId = mDialogLayoutRes; if (resId == 0) { return null; } LayoutInflater inflater = LayoutInflater.from(context); return inflater.inflate(resId, null); }
From source file:net.evecom.androidecssp.gps.ResourceItemizedOverlayActivity.java
/** * /* w w w .j a v a 2 s . c o m*/ * * * @author Mars zhang * @created 2015-12-8 2:48:19 */ private void initAroundDialog() { View dialogView = LayoutInflater.from(ResourceItemizedOverlayActivity.this) .inflate(R.layout.base_wheel_view, null); dialogNameEd = (EditText) dialogView.findViewById(R.id.base_wheel_view_name_ed); WheelView wheelView = (WheelView) dialogView.findViewById(R.id.country); wheelView.setVisibleItems(1); wheelView.setViewAdapter(new CountryAdapter(ResourceItemizedOverlayActivity.this, aroundNum)); wheelView.addScrollingListener(new OnWheelScrollListener() { public void onScrollingStarted(WheelView wheel) { } public void onScrollingFinished(WheelView wheel) { aroundChouseValue = aroundNum[tempindex]; } }); wheelView.addChangingListener(new OnWheelChangedListener() { public void onChanged(WheelView wheel, int oldValue, int newValue) { tempindex = newValue; } }); wheelView.setCurrentItem(0); aroundChouseValue = aroundNum[1]; tempindex = 0; // resourceType = resourceTypehashmap.keySet().toArray(new String[resourceTypehashmap.size()]); WheelView resourceWheelView = (WheelView) dialogView.findViewById(R.id.country_resource_type); resourceWheelView.setVisibleItems(1); resourceWheelView.setViewAdapter(new CountryAdapter(ResourceItemizedOverlayActivity.this, resourceType)); resourceWheelView.addScrollingListener(new OnWheelScrollListener() { public void onScrollingStarted(WheelView wheel) { } public void onScrollingFinished(WheelView wheel) { resourceTypeChouseValue = resourceType[resourceTypetempindex]; } }); resourceWheelView.addChangingListener(new OnWheelChangedListener() { public void onChanged(WheelView wheel, int oldValue, int newValue) { resourceTypetempindex = newValue; } }); if (resourceType.length > 1) { resourceWheelView.setCurrentItem(0); resourceTypeChouseValue = resourceType[1]; resourceTypetempindex = 0; } delDia = new AlertDialog.Builder(ResourceItemizedOverlayActivity.this) .setIcon(R.drawable.qq_dialog_default_icon).setTitle("").setView(dialogView) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dia, int which) { final Message message = new Message(); new Thread(new Runnable() { @Override public void run() { if (null == centerGpsPoint) { return; } HashMap<String, String> mEntityMap = new HashMap<String, String>(); int maround = Integer.parseInt(aroundChouseValue); double longdiffer = GpsUtil.getLongDifferFromMeters(mMapView, maround, ResourceItemizedOverlayActivity.this, centerGpsPoint); double latdiffer = GpsUtil.getLatDifferFromMeters(mMapView, maround, ResourceItemizedOverlayActivity.this, centerGpsPoint); mEntityMap.put("longdiffer", longdiffer + ""); mEntityMap.put("latdiffer", latdiffer + ""); mEntityMap.put("centergisy", centerGpsPoint.getLatitudeE6() / 1E6 + ""); mEntityMap.put("centergisx", centerGpsPoint.getLongitudeE6() / 1E6 + ""); mEntityMap.put("pagesize", HttpUtil.getPageSize(instance)); mEntityMap.put("resourcename", ifnull(dialogNameEd.getText().toString().trim(), "")); mEntityMap.put("resourcetype", ifnull(resourceTypehashmap.get(resourceTypeChouseValue), "")); try { String mResult = connServerForResultPost( "jfs/ecssp/mobile/eventCtr/searchResourceAround", mEntityMap); resourceModels = getObjsInfo(mResult); message.what = MESSAGETYPE_01; } catch (ClientProtocolException e) { message.what = MESSAGETYPE_02; } catch (IOException e) { message.what = MESSAGETYPE_02; } catch (JSONException e) { message.what = MESSAGETYPE_02; } pubhandler.sendMessage(message); } }).start(); dia.dismiss(); } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dia, int which) { dia.dismiss(); } }).create(); }
From source file:com.actionbarsherlock.widget.ActivityChooserView.java
/** * Create a new instance./* ww w .j av a 2 s. c o m*/ * * @param context The application environment. * @param attrs A collection of attributes. * @param defStyle The default style to apply to this view. */ public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context; TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.SherlockActivityChooserView, defStyle, 0); mInitialActivityCount = attributesArray.getInt(R.styleable.SherlockActivityChooserView_initialActivityCount, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable(R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable); attributesArray.recycle(); LayoutInflater inflater = LayoutInflater.from(mContext); inflater.inflate(R.layout.abs__activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image); mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button); mExpandActivityOverflowButton.setOnClickListener(mCallbacks); mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton .findViewById(R.id.abs__image); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); mAdapter = new ActivityChooserViewAdapter(); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); updateAppearance(); } }); Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); }
From source file:net.oschina.app.ui.MainActivity.java
private void initTabs() { MainTab[] tabs = MainTab.values();// ww w . jav a 2 s. co m final int size = tabs.length; for (int i = 0; i < size; i++) { MainTab mainTab = tabs[i]; TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName())); View indicator = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null); TextView title = (TextView) indicator.findViewById(R.id.tab_title); Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon()); title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); if (i == 2) { indicator.setVisibility(View.INVISIBLE); mTabHost.setNoTabChangedTag(getString(mainTab.getResName())); } title.setText(getString(mainTab.getResName())); tab.setIndicator(indicator); tab.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(MainActivity.this); } }); mTabHost.addTab(tab, mainTab.getClz(), null); if (mainTab.equals(MainTab.ME)) { View cn = indicator.findViewById(R.id.tab_mes); mBvNotice = new BadgeView(MainActivity.this, cn); mBvNotice.setBadgePosition(BadgeView.POSITION_TOP_RIGHT); mBvNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); mBvNotice.setBackgroundResource(R.drawable.notification_bg); mBvNotice.setGravity(Gravity.CENTER); } mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this); } }