List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:net.olejon.mdapp.LvhAdapter.java
@Override public CategoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.activity_lvh_card, viewGroup, false);//w w w.ja va 2 s. co m return new CategoryViewHolder(view); }
From source file:com.gb.cwsup.activity.CarListActivity.java
private void initView() { inflater = LayoutInflater.from(this); loadingDialog = new LoadingDialog(this); mhandler = new Handler(); nocar = (LinearLayout) findViewById(R.id.carlist_nomsg); carListView = (ListView) findViewById(R.id.carlist_ListView); carListView.setOnItemClickListener(new OnItemClickListener() { @Override// w w w . ja v a2 s.c o m public void onItemClick(AdapterView<?> arg0, View arg1, int item, long arg3) { CarBean car = cars.get(item); if (!TextUtils.isEmpty(TYPE) && TYPE.equals("CHOICE")) { Map<String, Object> data = new HashMap<String, Object>(1); data.put("choiceCAR", car); EventBus.getDefault().post(data); finish(); return; } Intent intent = new Intent(CarListActivity.this, CarAddActivity.class); intent.putExtra("CAR", car); intent.putExtra("type", "UPDATE"); CarListActivity.this.startActivity(intent); } }); }
From source file:com.amanmehara.programming.android.adapters.DetailAdapter.java
@Override public DetailAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.files_list, viewGroup, false); return new ViewHolder(view); }
From source file:org.flakor.androidtool.net.net.HistoryTask.java
@Override protected void onPostExecute(Integer i) { if (i < 0) { if (dialog != null) dialog.dismiss();//from w ww . ja va2 s . c o m Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } else if (i >= 0) { View view = LayoutInflater.from(context).inflate(R.layout.dialog_history, null); ListView list = (ListView) view.findViewById(R.id.history_list); if (i == 0) { TextView noHistory = (TextView) view.findViewById(R.id.no_history); noHistory.setVisibility(View.VISIBLE); list.setVisibility(View.GONE); } else { RemoteHistoryAdapter adapter = new RemoteHistoryAdapter(context); list.setAdapter(adapter); } TextView title = (TextView) view.findViewById(R.id.dialog_title); title.setText("??"); Button okBtn = (Button) view.findViewById(R.id.ok_btn); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.setContentView(view); Toast.makeText(context, "??", Toast.LENGTH_SHORT).show(); } else { if (dialog != null) dialog.dismiss(); Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } }
From source file:com.layer.atlas.cells.GeoCell.java
@Override public View onBind(final ViewGroup cellContainer) { ViewGroup cellRoot = (ViewGroup) Tools.findChildById(cellContainer, R.id.atlas_view_messages_cell_geo); if (cellRoot == null) { cellRoot = (ViewGroup) LayoutInflater.from(cellContainer.getContext()) .inflate(R.layout.atlas_view_messages_cell_geo, cellContainer, false); if (debug) Log.w(TAG, "geo.onBind() inflated geo cell"); }//from w w w . j a v a 2s .c om ImageView geoImageMy = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_my); ImageView geoImageTheir = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_their); View containerMy = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_my); View containerTheir = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_their); boolean myMessage = messagesList.getLayerClient().getAuthenticatedUserId() .equals(messagePart.getMessage().getSender().getUserId()); if (myMessage) { containerMy.setVisibility(View.VISIBLE); containerTheir.setVisibility(View.GONE); } else { containerMy.setVisibility(View.GONE); containerTheir.setVisibility(View.VISIBLE); } ImageView geoImage = myMessage ? geoImageMy : geoImageTheir; ShapedFrameLayout cellCustom = (ShapedFrameLayout) (myMessage ? containerMy : containerTheir); Object imageId = messagePart.getId(); Bitmap bmp = (Bitmap) Atlas.imageLoader.getImageFromCache(imageId); if (bmp != null) { if (debug) Log.d(TAG, "geo.onBind() bitmap: " + bmp.getWidth() + "x" + bmp.getHeight()); geoImage.setImageBitmap(bmp); } else { if (debug) Log.d(TAG, "geo.onBind() spec: " + spec); geoImage.setImageDrawable(Tools.EMPTY_DRAWABLE); // schedule image File tileFile = getTileFile(cellContainer.getContext()); if (tileFile.exists()) { if (debug) Log.d(TAG, "geo.onBind() decodeImage: " + tileFile); // request decoding spec = Atlas.imageLoader.requestImage(imageId, new Atlas.FileStreamProvider(tileFile), (int) Tools.getPxFromDp(150, cellContainer.getContext()), (int) Tools.getPxFromDp(150, cellContainer.getContext()), false, this); } else { int width = 300; int height = 300; int zoom = 16; final String url = new StringBuilder().append("https://maps.googleapis.com/maps/api/staticmap?") .append("format=png32&").append("center=").append(lat).append(",").append(lon).append("&") .append("zoom=").append(zoom).append("&").append("size=").append(width).append("x") .append(height).append("&").append("maptype=roadmap&").append("markers=color:red%7C") .append(lat).append(",").append(lon).toString(); Atlas.downloadQueue.schedule(url, tileFile, this); if (debug) Log.d(TAG, "geo.onBind() show stub and download image: " + tileFile); } } // clustering cellCustom.setCornerRadiusDp(16, 16, 16, 16); if (AtlasMessagesList.CLUSTERED_BUBBLES) { if (myMessage) { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 2, 16); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(16, 2, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 2, 2, 16); } } else { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 16, 2); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(2, 16, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(2, 16, 16, 2); } } } return cellRoot; }
From source file:net.olejon.mdapp.DiseasesAndTreatmentsSearchAdapter.java
@Override public DiseasesAndTreatmentsSearchViewHolder onCreateViewHolder(final ViewGroup viewGroup, final int i) { View view = LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.activity_diseases_and_treatments_search_card, viewGroup, false); return new DiseasesAndTreatmentsSearchViewHolder(view); }
From source file:cn.newgxu.android.notty.ui.LoginBoxFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View v = LayoutInflater.from(getActivity()).inflate(R.layout.login, null); final EditText account = (EditText) v.findViewById(R.id.account); final EditText pwd = (EditText) v.findViewById(R.id.password); return new AlertDialog.Builder(getActivity()).setCancelable(false).setTitle(R.string.login_box) .setIcon(StyleUtils.getThemeDependentAttr(getActivity().getTheme(), R.attr.user_icon)).setView(v) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override/*from w w w . ja v a 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { progressDialog = ProgressDialog.show(getActivity(), "login...", "login..."); new Handler().post(new Runnable() { @Override public void run() { String _account = account.getEditableText().toString(); String _pwd = pwd.getEditableText().toString(); NottyApplication app = NottyApplication.getApp(); SharedPreferences prefs = app.getPrefs(); try { JSONObject result = RESTMethod .get(C.DOMAIN + "/info/login?account=" + _account + "&pwd=" + _pwd); if (result.getInt(C.STATUS) == C.OK) { // put the account and pwd to the app' s context. SharedPreferences.Editor editor = NottyApplication.getApp().getPrefs() .edit(); editor.putString(C.ACCOUNT, _account); editor.putString(C.PWD, _pwd); JSONObject u = result.getJSONObject(C.USER); editor.putLong(C._ID, u.getLong(C.ID)); editor.putString(C.user.AUTHED_NAME, u.getString(C.user.AUTHED_NAME)); editor.commit(); Toast.makeText(getActivity(), R.string.login_ok, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getActivity(), UserServiceActivity.class); startActivity(intent); } else { Toast.makeText(getActivity(), getString(R.string.login_no) + ": " + result.getString(C.MSG), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { L.wtf(TAG, "error when try to login in the thread.", e); } } }); progressDialog.dismiss(); // new Thread(new Runnable() { // @Override // public void run() { // try { // Thread.sleep(3000); // JSONObject result = RESTMethod.get(C.DOMAIN // + "/info/login?account=" + _account + "&pwd=" + _pwd); // if (result.getInt(C.STATUS) == C.OK) { //// put the account and pwd to the app' s context. // SharedPreferences.Editor editor = NottyApplication.getApp().getPrefs().edit(); // editor.putString(C.ACCOUNT, _account); // editor.putString(C.PWD, _pwd); // editor.commit(); // Toast.makeText(getActivity(), R.string.login_ok, Toast.LENGTH_SHORT).show(); // } else { // Toast.makeText(getActivity(), R.string.login_no + ": " // + result.getString(C.MSG), Toast.LENGTH_SHORT).show(); // } // } catch (Exception e) { // L.wtf(TAG, "error when try to login in the thread.", e); // } finally { // progressDialog.dismiss(); // } // } // }).start(); } }).setNegativeButton(R.string.no, null).create(); }
From source file:biz.easymenu.easymenung.MenuPagerAdapter.java
public MenuPagerAdapter(Context context, boolean isDrinks) { this.context = context; ItemAdaptersList = new ArrayList<ItemAdapter>(); li = LayoutInflater.from(context); DBContentProvider dbc = new DBContentProvider(context); this.isDrinks = isDrinks; menuTitles = dbc.getMenuTitles(isDrinks); dbc.close();/*from w w w.j av a2 s . c o m*/ emp = new EmPrefs(context); }
From source file:com.manning.androidhacks.hack023.adapter.TodoAdapter.java
public TodoAdapter(Activity activity) { super(activity, getManagedCursor(activity), true); mActivity = activity;/* w w w. j a v a 2 s . com*/ mInflater = LayoutInflater.from(activity); final Cursor c = getCursor(); mInternalIdIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_ID); mTitleIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_TITLE); mInternalStatusIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_STATUS_FLAG); }
From source file:br.com.testmaster.view.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(getResources().getString(R.string.main_activity_title)); setSupportActionBar(toolbar);/*w w w. j av a 2s . c om*/ tabLayout = (TabLayout) findViewById(R.id.tabs); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); //Para evitar o uso de ViewPager //--------------------------------------------------------------------------------------------- TextView tabOffer = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabOffer.setText("Disponveis"); tabOffer.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_basket, 0, 0, 0); TextView tabLead = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); tabLead.setText("Aceitos"); tabLead.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_check, 0, 0, 0); //create tabs title tabLayout.addTab(tabLayout.newTab().setCustomView(tabOffer)); tabLayout.addTab(tabLayout.newTab().setCustomView(tabLead)); //replace default fragment replaceFragment(new OffersFragment()); //handling tab click event tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { if (tab.getPosition() == 0) { replaceFragment(new OffersFragment()); } else if (tab.getPosition() == 1) { replaceFragment(new LeadsFragment()); } } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); }