List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:net.issarlk.androbunny.AndrobunnyApp.java
public void onCreate() { // Initialization of ACRA ACRA.init(this); this.uiThread = Thread.currentThread(); //Get layout inflater layoutInflater = LayoutInflater.from(this); super.onCreate(); //Get density Androbunny.it().setScale(this.getResources().getDisplayMetrics().density); Log.d(TAG, "Starting Inkbunny APP"); //Load default values from the xml into preferences. PreferenceManager.setDefaultValues(this, R.xml.preference, false); //Get preference manager for further use. Preference.it().setSharedPreferences(PreferenceManager.getDefaultSharedPreferences(this)); //Set SID in API if saved in preferences if (Preference.it().has("sid")) { API.it().getSID().set(Preference.it().getString("sid")); }// ww w . ja v a 2s .co m if (Preference.it().has("ratingsmask")) { API.it().setRatingsmask(Preference.it().getString("ratingsmask")); } else if (API.it().getSID().get() != null) { //The user is logged in, but we don't have her ratingsmask. //She needs to log in again... log her out API.it().logout(); } //Check for update this.worker.execute(new Updater()); //Start cache cleaner thread new CacheCleaner().run(); //Check in the background whether we are logged in or not. final String username = Preference.it().getString("username"); worker.execute(new Runnable() { @Override public void run() { ABUser.it().checkLoggedInAs(username); } }); }
From source file:android.support.v7.app.ToolbarActionBar.java
@Override public void setCustomView(int resId) { final LayoutInflater inflater = LayoutInflater.from(mDecorToolbar.getContext()); setCustomView(inflater.inflate(resId, mDecorToolbar.getViewGroup(), false)); }
From source file:com.android.browser.view.BookmarkExpandableView.java
public void setColumnWidthFromLayout(int layout) { LayoutInflater infalter = LayoutInflater.from(mContext); View v = infalter.inflate(layout, this, false); v.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); mColumnWidth = v.getMeasuredWidth(); }
From source file:com.viettel.view.MainHome.SelectEventPlace.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater lf = LayoutInflater.from(this); app = lf.inflate(R.layout.layout_select_event_place, null); setContentView(app);/*from ww w .jav a 2 s . c om*/ cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present isInternetPresent = cd.isConnectingToInternet(); if (!isInternetPresent) { // Internet Connection is not present alertDialog.show(this, getResources().getString(R.string.INTERNET_CONNECTION_ERROR), getResources().getString(R.string.SETUP_CONNECTION), false); // stop executing code by return return; } // creating GPS Class object gps = new GPSTracker(SelectEventPlace.this); // check if GPS location can get if (!gps.canGetLocation()) { // Can't get user's current location alertDialog.show(this, getResources().getString(R.string.GPS_STATUS), getResources().getString(R.string.REQUIRE_ENABLE_GPS), false); return; } bindComponents(); btnSearchPlace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new LoadPlaces().execute(); } }); listViewPlace.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int postion, long id) { String placeDetail = placeDataList.get(postion).getTxt_Name() + "," + placeDataList.get(postion).getTxt_Address(); Intent intent = new Intent(SelectEventPlace.this, CreateNewEvent.class); intent.putExtra("EVENT_PLACE", placeDetail); startActivity(intent); } }); btnDefaultPlace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String placeDetail = getResources().getString(R.string.PLACE_DEFAULT); Intent intent = new Intent(SelectEventPlace.this, CreateNewEvent.class); intent.putExtra("EVENT_PLACE", placeDetail); startActivity(intent); } }); final View[] children = new View[] { app }; }
From source file:nya.miku.wishmaster.ui.settings.AutohideActivity.java
@SuppressLint("InflateParams") @Override/*from ww w . j a v a 2s .c om*/ protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Object item = l.getItemAtPosition(position); final int changeId; if (item instanceof AutohideRule) { changeId = position - 1; } else { changeId = -1; //-1 - ? } Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new ContextThemeWrapper(this, R.style.Neutron_Medium) : this; View dialogView = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_autohide_rule, null); final EditText regexEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_regex); final Spinner chanSpinner = (Spinner) dialogView.findViewById(R.id.dialog_autohide_chan_spinner); final EditText boardEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_boardname); final EditText threadEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_threadnum); final CheckBox inCommentCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_comment); final CheckBox inSubjectCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_subject); final CheckBox inNameCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_name); chanSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, chans)); if (changeId != -1) { AutohideRule rule = (AutohideRule) item; regexEditText.setText(rule.regex); int chanPosition = chans.indexOf(rule.chanName); chanSpinner.setSelection(chanPosition != -1 ? chanPosition : 0); boardEditText.setText(rule.boardName); threadEditText.setText(rule.threadNumber); inCommentCheckBox.setChecked(rule.inComment); inSubjectCheckBox.setChecked(rule.inSubject); inNameCheckBox.setChecked(rule.inName); } else { chanSpinner.setSelection(0); } DialogInterface.OnClickListener save = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String regex = regexEditText.getText().toString(); if (regex.length() == 0) { Toast.makeText(AutohideActivity.this, R.string.autohide_error_empty_regex, Toast.LENGTH_LONG) .show(); return; } try { Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL); } catch (Exception e) { CharSequence message = null; if (e instanceof PatternSyntaxException) { String eMessage = e.getMessage(); if (!TextUtils.isEmpty(eMessage)) { SpannableStringBuilder a = new SpannableStringBuilder( getString(R.string.autohide_error_incorrect_regex)); a.append('\n'); int startlen = a.length(); a.append(eMessage); a.setSpan(new TypefaceSpan("monospace"), startlen, a.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); message = a; } } if (message == null) message = getString(R.string.error_unknown); Toast.makeText(AutohideActivity.this, message, Toast.LENGTH_LONG).show(); return; } AutohideRule rule = new AutohideRule(); int spinnerSelectedPosition = chanSpinner.getSelectedItemPosition(); rule.regex = regex; rule.chanName = spinnerSelectedPosition > 0 ? chans.get(spinnerSelectedPosition) : ""; // 0 ? = ? rule.boardName = boardEditText.getText().toString(); rule.threadNumber = threadEditText.getText().toString(); rule.inComment = inCommentCheckBox.isChecked(); rule.inSubject = inSubjectCheckBox.isChecked(); rule.inName = inNameCheckBox.isChecked(); if (!rule.inComment && !rule.inSubject && !rule.inName) { Toast.makeText(AutohideActivity.this, R.string.autohide_error_no_condition, Toast.LENGTH_LONG) .show(); return; } if (changeId == -1) { rulesJson.put(rule.toJson()); } else { rulesJson.put(changeId, rule.toJson()); } rulesChanged(); } }; AlertDialog dialog = new AlertDialog.Builder(this).setView(dialogView) .setTitle(changeId == -1 ? R.string.autohide_add_rule_title : R.string.autohide_edit_rule_title) .setPositiveButton(R.string.autohide_save_button, save) .setNegativeButton(android.R.string.cancel, null).create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapter.java
@Override public View getView(final int position, View cView, ViewGroup parent) { ViewHolder holder = null;/*from w ww . 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); 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.image, contents.advice_image); return cView; }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapter2.java
@Override public View getView(final int position, View cView, ViewGroup parent) { ViewHolder holder = null;/*from ww w . j a v a 2 s .c o 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.linear = (ImageView) cView.findViewById(R.id.image); holder.li = (LinearLayout) cView.findViewById(R.id.LinearLayout1); 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(); 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()) { // BitmapFactory.Options opt=new BitmapFactory.Options(); // opt.inSampleSize=2; // Bitmap bm=BitmapFactory.decodeFile(f1.toString(),opt); // //bm=Bitmap.createScaledBitmap(bm, 101,69, true); // BitmapDrawable draw=new BitmapDrawable(bm); // holder.linear.setBackgroundDrawable(draw); //// holder.linear.setImageURI(Uri.fromFile(f1)); // //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView); // // } else { // new DownTask().execute( // (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.linear); // // } requestMyImage(holder.loading, holder.loadinglinear, holder.linear, contents.advice_image); return cView; }
From source file:com.baochu.androidassignment.login.ProfileFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.profile_fragment, container, false); mProfilePictureView = (ProfilePictureView) view.findViewById(R.id.profile_Picture); mProfilePictureView.setCropped(true); mUserInfo = (TextView) view.findViewById(R.id.user_info); mAlbumButton = (Button) view.findViewById(R.id.album_button); mAlbumButton.setOnClickListener(new OnClickListener() { @Override/*w w w . j a v a 2 s . com*/ public void onClick(View v) { Context context = ProfileFragment.this.getActivity(); Intent intent = new Intent(context, AlbumActivity.class); context.startActivity(intent); } }); mLocationButton = (Button) view.findViewById(R.id.location_button); mLocationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Context context = ProfileFragment.this.getActivity(); Intent intent = new Intent(context, GMSMapActivity.class); context.startActivity(intent); } }); mGCMMessageButton = (Button) view.findViewById(R.id.gcm_message_button); mGCMMessageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Context context = ProfileFragment.this.getActivity(); Intent intent = new Intent(context, NotificationEntryActivity.class); context.startActivity(intent); } }); mStatusListView = (ListView) view.findViewById(R.id.status_list); View header = LayoutInflater.from(getActivity()).inflate(R.layout.status_list_header, null); mStatusListView.addHeaderView(header, null, false); mStatusListAdapter = new StatusListAdapter(getActivity()); mStatusListView.setAdapter(mStatusListAdapter); return view; }
From source file:com.example.activity.ProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.profile_list); title = (TextView) findViewById(R.id.topview_title); back = (ImageView) findViewById(R.id.topview_back); listView = (ListView) findViewById(R.id.profile_shots_list); Intent intent = getIntent();//w ww . ja v a 2 s. c om playerId = intent.getIntExtra(PLAYER_ID, 1); title.setText(""); back.setVisibility(View.VISIBLE); back.setOnClickListener(this); headView = LayoutInflater.from(this).inflate(R.layout.profile, null); bottomView = LayoutInflater.from(this).inflate(R.layout.profile_bottom, null); head = (ImageView) headView.findViewById(R.id.profile_head); name = (TextView) headView.findViewById(R.id.profile_name); location = (TextView) headView.findViewById(R.id.profile_location); net = (TextView) headView.findViewById(R.id.profile_net); shots_count = (TextView) headView.findViewById(R.id.profile_shots_count); likes_count = (TextView) headView.findViewById(R.id.profile_likes_count); following_count = (TextView) headView.findViewById(R.id.profile_following_count); followers_count = (TextView) headView.findViewById(R.id.profile_followers_count); shots_view = (LinearLayout) headView.findViewById(R.id.profile_shots_view); likes_view = (LinearLayout) headView.findViewById(R.id.profile_likes_view); following_view = (LinearLayout) headView.findViewById(R.id.profile_following_view); followers_view = (LinearLayout) headView.findViewById(R.id.profile_followers_view); more = (LinearLayout) bottomView.findViewById(R.id.profile_bottom_more); LayoutParams params = head.getLayoutParams(); params.width = getWindowManager().getDefaultDisplay().getWidth() / 4; params.height = params.width; head.setLayoutParams(params); listView.addHeaderView(headView); listView.addFooterView(bottomView); head.setOnClickListener(this); shots_view.setOnClickListener(this); likes_view.setOnClickListener(this); following_view.setOnClickListener(this); followers_view.setOnClickListener(this); more.setOnClickListener(this); playerModel = new PlayerModel(this); playerModel.addResponseListener(this); playerModel.getPlayer(playerId); playerModel.getProfileShotList(playerId); }
From source file:org.n52.geoar.data.sos.SOSFeatureVisualization.java
@Override public View getFeatureView(SpatialEntity2<? extends Geometry> entity, View convertView, ViewGroup parentView, Context activityContext) { ViewHolder viewHolder;//from w w w .j a va 2 s . com if (convertView == null) { convertView = LayoutInflater.from(activityContext).inflate(R.layout.sos_featureview, null); viewHolder = new ViewHolder(); viewHolder.textViewServiceSensorId = (TextView) convertView.findViewById(R.id.textViewServiceSensorId); viewHolder.textViewDescription = (TextView) convertView.findViewById(R.id.textViewDescription); viewHolder.textViewName = (TextView) convertView.findViewById(R.id.textViewName); viewHolder.sosObservationView = (SOSObservationView) convertView.findViewById(R.id.sosObservationView); viewHolder.sosObservationView.setCapabilitiesCallable(viewHolder.capabilitiesCallable); viewHolder.sosObservationView.setObservationCallable(viewHolder.observationCallable); viewHolder.sosObservationView.setActivityContext(activityContext); TabHost tabHost = (TabHost) convertView.findViewById(android.R.id.tabhost); tabHost.setup(); tabHost.addTab(tabHost.newTabSpec("FOI").setIndicator("Feature").setContent(R.id.scrollViewFOI)); tabHost.addTab(tabHost.newTabSpec("SOS").setIndicator("Observations").setContent(R.id.layoutSOS)); tabHost.setCurrentTab(0); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } if (entity instanceof FOI) { viewHolder.featureOfInterest = (FOI) entity; viewHolder.textViewName.setText(viewHolder.featureOfInterest.name); if (viewHolder.featureOfInterest.description != null) { viewHolder.textViewDescription.setText(Html.fromHtml(viewHolder.featureOfInterest.description)); } viewHolder.textViewServiceSensorId.setText(viewHolder.featureOfInterest.id); } return convertView; }