List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:at.amartinz.hardware.sensors.BaseSensor.java
public BaseSensor(final Context context) { super(context, null); mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); mInflater = LayoutInflater.from(context); final View v = LayoutInflater.from(context).inflate(R.layout.hardware_card_with_container, this, false); super.addView(v); mCardView = (CardView) findViewById(R.id.card_view_root); if (sBackgroundColorGlobal != Integer.MIN_VALUE) { mCardView.setCardBackgroundColor(sBackgroundColorGlobal); }/* w w w.ja v a 2s . c om*/ final FrameLayout container = (FrameLayout) findViewById(R.id.layout_container); mInflater.inflate(R.layout.hardware_item_sensor, container, true); mIcon = (ImageView) findViewById(R.id.sensor_icon); mIcon.setImageDrawable(getSensorImage()); mTitle = (TextView) findViewById(R.id.sensor_label); mName = (TextView) findViewById(R.id.sensor_name); mVendor = (TextView) findViewById(R.id.sensor_vendor); mPowerUsage = (TextView) findViewById(R.id.sensor_power_usage); mDataContainer = (LinearLayout) findViewById(R.id.sensor_data_container); }
From source file:com.actionbarsherlock.internal.view.menu.MenuPopupHelper.java
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly) { mContext = context;//w ww .j a va 2 s. c o m mInflater = LayoutInflater.from(context); mMenu = menu; mOverflowOnly = overflowOnly; final Resources res = context.getResources(); mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, res.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth)); mAnchorView = anchorView; menu.addMenuPresenter(this); }
From source file:com.tedx.activities.LazyActivity.java
protected void setEmptyView(int resId) { setEmptyView(LayoutInflater.from(this).inflate(resId, null)); }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapterdetail.java
@Override public View getView(final int position, View cView, ViewGroup parent) { ViewHolder holder = null;//w w w . j a v a2s. co m final SimilarItem contents = list.get(position); final SharedPreferences pref = mContext.getSharedPreferences("pref", mContext.MODE_PRIVATE); final SharedPreferences.Editor editor = pref.edit(); if (cView == null) { //cView=View.inflate(mContext, layout,null); cView = LayoutInflater.from(mContext).inflate(layout, parent, false); holder = new ViewHolder(); holder.image = (ImageView) cView.findViewById(R.id.image); holder.loading = (ImageView) cView.findViewById(R.id.loadingimg); holder.loading.setVisibility(View.GONE); holder.loading.setBackgroundResource(R.anim.progress); holder.loadinglinear = (LinearLayout) cView.findViewById(R.id.loading); holder.loadinglinear.setVisibility(View.GONE); loadingViewAnim = (AnimationDrawable) holder.loading.getBackground(); // holder.question=(TextView)cView.findViewById(R.id.question); // holder.date=(TextView)cView.findViewById(R.id.date); cView.setTag(holder); // Log.v(TAG,"cvew==null"); } else { holder = (ViewHolder) cView.getTag(); // Log.v(TAG,"cvew!=null"); } //holder.image.setImageResource(contents.getRes()); // String DirPath = Environment.getExternalStorageDirectory() // .getAbsolutePath(); // DirPath = DirPath + "/" + "KidsMind2" + "/"; // // File cameraDir = new File(DirPath); // if (!cameraDir.exists()) { // // cameraDir.mkdirs(); // } // File f1 = new File(cameraDir, contents.advice_image); // if (f1.exists()) { // holder.image.setImageURI(Uri.fromFile(f1)); // //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView); // // } else { // new DownTask().execute( // (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.image); // // } requestMyImage(holder.loading, holder.loadinglinear, holder.image, contents.advice_image); // if("Q1".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q2".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q3".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q4".equals(contents.question_id)){ // holder.question.setText(" "); // } // String da=contents.getDate().substring(0, 9); // holder.date.setText(da); return cView; }
From source file:com.owncloud.android.ui.adapter.NotificationListAdapter.java
@NonNull @Override/*from ww w. j a v a 2 s . c om*/ public NotificationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View v = LayoutInflater.from(notificationsActivity).inflate(R.layout.notification_list_item, parent, false); return new NotificationViewHolder(v); }
From source file:com.example.parking.ParkingInformationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDBAdapter = new DBAdapter(this); setContentView(R.layout.activity_parking_information); mParkNameTV = (TextView) findViewById(R.id.tv_parking_name); mParkNameTV.setText(R.string.park_name_fixed); mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number); mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed)); mCarType = (Spinner) findViewById(R.id.sp_car_type); mParkingType = (Spinner) findViewById(R.id.sp_parking_type); mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location); mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number); Intent intent = getIntent();//from w ww . j ava 2s .c om Bundle bundle = intent.getExtras(); mLicensePlateNumberTV.setText(bundle.getString("licensePlate")); mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving); new TimeThread().start(); mOkButton = (Button) findViewById(R.id.bt_confirm_arriving); mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(), mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(), Integer.parseInt(mLocationNumber.getSelectedItem().toString()), DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null, "")); mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving); mPhotoBT.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mEnterImage != null) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT) .show(); } else { openTakePhoto(); } } }); mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving); mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving); mEnterImageIV.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create(); ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image); Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image); img.setImageBitmap(mEnterImage); dialog.setView(imgEntryView); // dialog dialog.show(); imgEntryView.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { dialog.cancel(); } }); deleteBT.setOnClickListener(new OnClickListener() { public void onClick(View paramView) { mEnterImage = null; mEnterImageIV.setImageResource(drawable.ic_photo_background_64px); dialog.cancel(); } }); } }); getActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter filter = new IntentFilter(); filter.addAction("ExitApp"); registerReceiver(mReceiver, filter); }
From source file:com.hackensack.umc.activity.ProfileSelfieActivityCustomeCam.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_profile_selfie); getSupportActionBar().setDisplayHomeAsUpEnabled(true); frameLayout = new FrameLayout(this); // creating LayoutParams FrameLayout.LayoutParams frameLayoutParam = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); // set LinearLayout as a root element of the screen setContentView(frameLayout, frameLayoutParam); layoutInflater = LayoutInflater.from(this); View mainView = layoutInflater.inflate(R.layout.activity_profile_selfie, null, false); infalteXml(mainView);/* www. j av a 2 s.c om*/ frameLayout.addView(mainView); //setContentView(R.layout.activity_list); }
From source file:com.xorcode.andtweet.TweetListActivity.java
/** * Called when the activity is first created. * /*from ww w .ja v a2 s . com*/ * @see android.app.Activity#onCreate(android.os.Bundle) * @param savedInstanceState */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (MyLog.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "onCreate"); } // Create list footer for loading messages mListFooter = new LinearLayout(getApplicationContext()); mListFooter.setClickable(false); getListView().addFooterView(mListFooter); LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); View tv = inflater.inflate(R.layout.item_loading, null); mListFooter.addView(tv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); mListFooter.setVisibility(View.INVISIBLE); getListView().setOnScrollListener(this); initUI(); }
From source file:com.moto.miletus.application.DeviceListAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // create a new view View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.listitem_device, parent, false); return new ViewHolder(v, (TextView) v.findViewById(R.id.device_title), (TextView) v.findViewById(R.id.device_description), (ImageView) v.findViewById(R.id.device_picture), (ImageView) v.findViewById(R.id.ble_picture)); }
From source file:com.sym.demozxing.zxing.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent();/*from w w w. j a v a 2 s . c o m*/ if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }