List of usage examples for android.view LayoutInflater inflate
public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot)
From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapter.java
@NonNull @Override//from w w w .j a va2 s . c o m public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater layoutInflater = MainContext.INSTANCE.getMainActivity().getLayoutInflater(); view = layoutInflater.inflate(R.layout.channel_rating_details, parent, false); } WiFiChannel wiFiChannel = getItem(position); if (wiFiChannel == null) { return view; } ((TextView) view.findViewById(R.id.channelNumber)) .setText(String.format(Locale.ENGLISH, "%d", wiFiChannel.getChannel())); ((TextView) view.findViewById(R.id.accessPointCount)) .setText(String.format(Locale.ENGLISH, "%d", channelRating.getCount(wiFiChannel))); Strength strength = Strength.reverse(channelRating.getStrength(wiFiChannel)); RatingBar ratingBar = (RatingBar) view.findViewById(R.id.channelRating); int size = Strength.values().length; ratingBar.setMax(size); ratingBar.setNumStars(size); ratingBar.setRating(strength.ordinal() + 1); int color = ContextCompat.getColor(getContext(), strength.colorResource()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setRatingBarColor(ratingBar.getProgressDrawable(), color); } else { ratingBar.setProgressTintList(ColorStateList.valueOf(color)); } return view; }
From source file:de.geeksfactory.opacclient.frontend.AccountListAdapter.java
@SuppressWarnings("deprecation") @Override//ww w . ja v a 2s .c o m public View getView(int position, View contentView, ViewGroup viewGroup) { View view; // position always 0-7 if (objects.get(position) == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_account, viewGroup, false); return view; } Account item = objects.get(position); if (contentView == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_account, viewGroup, false); } else { view = contentView; } if (((OpacClient) ((Activity) context).getApplication()).getAccount().getId() == item.getId() && highlight) { view.findViewById(R.id.rlItem).setBackgroundColor(context.getResources().getColor(R.color.accent_red)); } else { // should be replaced by setBackground which is not available before API level 16 view.findViewById(R.id.rlItem).setBackgroundDrawable(null); } Library lib; try { lib = ((OpacClient) ((Activity) context).getApplication()).getLibrary(item.getLibrary()); TextView tvCity = (TextView) view.findViewById(R.id.tvCity); if (lib.getTitle() != null && !lib.getTitle().equals("null")) { tvCity.setText(lib.getCity() + "\n" + lib.getTitle()); } else { tvCity.setText(lib.getCity()); } } catch (IOException | JSONException e) { e.printStackTrace(); } TextView tvName = (TextView) view.findViewById(R.id.tvName); if (item.getName() != null) { tvName.setText(item.getName()); } TextView tvLabel = (TextView) view.findViewById(R.id.tvLabel); if (item.getLabel() != null) { tvLabel.setText(item.getLabel()); } return view; }
From source file:com.sakisds.icymonitor.fragments.disk.DiskFSFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mRootView = inflater.inflate(R.layout.fragment_list, container, false); mSettings = getActivity().getSharedPreferences(MainViewActivity.SHAREDPREFS_FILE, Context.MODE_PRIVATE); return mRootView; }
From source file:com.bodeme.easycloud.syncadapter.EnterCredentialsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.enter_credentials, container, false); textUrl = (TextView) v.findViewById(R.id.text_url); // protocol selection spinner textHttpWarning = (TextView) v.findViewById(R.id.http_warning); editURL = (EditText) v.findViewById(R.id.url); editURL.addTextChangedListener(this); editUserName = (EditText) v.findViewById(R.id.userName); editUserName.addTextChangedListener(this); editPassword = (EditText) v.findViewById(R.id.password); editPassword.addTextChangedListener(this); // Remove views for editing ownCloud-url, when constant is given if (Constants.OWNCLOUD_URL != null) { textUrl.setVisibility(View.GONE); editURL.setVisibility(View.GONE); textHttpWarning.setVisibility(View.GONE); }/*from w w w . j a va 2 s . co m*/ // ownCloud Type Spinner spnrType = (Spinner) v.findViewById(R.id.select_type); spnrType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { typePosition = position; } @Override public void onNothingSelected(AdapterView<?> parent) { typePosition = 0; } }); spnrType.setSelection(0); // hook into action bar setHasOptionsMenu(true); return v; }
From source file:es.uniovi.imovil.fcrtrainer.HighscoresFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = inflater.inflate(R.layout.fragment_highscores, container, false); initializeExerciseSpinner();/*from w w w.j a v a2 s . co m*/ // El ListView se inicializa porque cuando se carga el spinner, se // genera un evento onItemSelected del spinner return mRootView; }
From source file:fi.tuukka.weather.view.FragmentStations.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.asemat, container, false); rg = (RadioGroup) view.findViewById(R.id.radioGroup1); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*from ww w. j a v a 2 s .c om*/ public void onCheckedChanged(RadioGroup rg, int id) { if (listenCheck) { for (int i = 0; i < rg.getChildCount(); i++) { RadioButton btn = (RadioButton) rg.getChildAt(i); if (btn.getId() == id) { String text = (String) btn.getText(); Station station = new Station(text, null); changeStation(station); refreshStations(); return; } } } } }); EditText searchBox = (EditText) view.findViewById(R.id.stationSearchBox); searchBox.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String string = s.toString(); if (query == null || !query.equals(string)) { query = s.toString(); stationStrings = null; // mark as not finished ((ActivityMain) getActivity()).queryStations(); } } }); Activity activity = getActivity(); header = (TextView) view.findViewById(R.id.stationsHeader); int fontsize = Utils.getScaledFont(activity); int pad = Utils.dpToPx(5, activity); header.setTextAppearance(activity, R.style.TextStyle); header.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontsize); header.setPadding(0, pad, 0, pad); header.setText("Syt kunta/kunnanosa:"); super.onCreateView(inflater, container, savedInstanceState); return view; }
From source file:com.arquitetaweb.restaurantes.fragment.CardapioFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { contexto = this.getActivity(); final View view = inflater.inflate(R.layout.list_itens, container, false); handler = new Handler(); carregarDadosJson(view);// w ww . j a v a2s. com return view; }
From source file:com.embeddedlapps.primeraversion.ListAdapterHolder.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater mInflater = LayoutInflater.from(parent.getContext()); final View sView = mInflater.inflate(R.layout.single_list_item, parent, false); return new ViewHolder(sView); }
From source file:com.example.pyrkesa.frag.ScenarioDetail.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.scenario_detail, container, false); //userLayout = (Layout)getView().findViewById(R.id.user_layout); /* scenarioList=(ListView)rootView.findViewById(R.id.lt_scenario); /*w w w . ja v a 2s . c om*/ scenarioName = getResources().getStringArray(R.array.user_list_item); // load scenarioIcon = getResources().obtainTypedArray(R.array.scenarioIcons);// load icons from scenarioIconDel = getResources().obtainTypedArray(R.array.userIcons1); scenarioItems = new ArrayList<ScenarioItem>(); // adding user items new LoadAllScenario().execute(); */ return rootView; }
From source file:com.spoiledmilk.ibikecph.favorites.FavoritesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View view = inflater.inflate(getListRowLayout(), parent, false); TextView tv = (TextView) view.findViewById(R.id.textFavoriteName); String name = getItem(position).getName(); if (name.length() > 19) name = name.substring(0, 19) + "..."; tv.setText(name);/*from w w w .j a v a 2 s . c o m*/ tv.setTypeface(IbikeApplication.getNormalFont()); tv.setTextColor(getTextColor()); ImageButton btnEdit = (ImageButton) view.findViewById(R.id.btnEdit); final FavoritesData fd = getItem(position); tv.setPadding(getPadding(fd), 0, 0, 0); btnEdit.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { fragment.onEditFavorite(fd); } }); final ImageView imgIcon = ((ImageView) view.findViewById(R.id.icon)); if (!isEditMode) { imgIcon.setImageResource(getIconResourceId(getItem(position))); btnEdit.setVisibility(View.GONE); } else { imgIcon.setImageResource(R.drawable.fav_reorder); btnEdit.setVisibility(View.VISIBLE); } return view; }