use of android.widget.ExpandableListView in project Thrift-box by Sash0k.
the class ExpensesFragment method onCreateView.
// ============================================================================
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
View expandableListView = super.onCreateView(inflater, container, state);
CoordinatorLayout view = (CoordinatorLayout) inflater.inflate(R.layout.fragment_expenses, container, false);
// Удаляю заглушку и добавляю ExpandableListFragment
ListView lv = (ListView) view.findViewById(android.R.id.list);
ViewGroup parent = (ViewGroup) lv.getParent();
int lvIndex = parent.indexOfChild(lv);
parent.removeViewAt(lvIndex);
parent.addView(expandableListView, lvIndex, expandableListView.getLayoutParams());
// Привязываю fab к новому listView
lv = (ListView) view.findViewById(android.R.id.list);
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.expenses_fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent();
i.setClass(getContext(), StatisticsActivity.class);
startActivity(i);
}
});
fab.attachToListView(lv);
return view;
}
use of android.widget.ExpandableListView in project Osmand by osmandapp.
the class TrackPointFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mainView = inflater.inflate(R.layout.track_points_tree, container, false);
ExpandableListView listView = (ExpandableListView) mainView.findViewById(android.R.id.list);
setHasOptionsMenu(true);
overlayView = mainView.findViewById(R.id.overlay_view);
overlayView.setOnClickListener(onFabClickListener);
menuFab = (FloatingActionButton) mainView.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(onFabClickListener);
waypointFab = (FloatingActionButton) mainView.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(onFabClickListener);
waypointTextLayout = mainView.findViewById(R.id.waypoint_text_layout);
waypointTextLayout.setOnClickListener(onFabClickListener);
routePointFab = (FloatingActionButton) mainView.findViewById(R.id.route_fab);
routePointFab.setOnClickListener(onFabClickListener);
routePointTextLayout = mainView.findViewById(R.id.route_text_layout);
routePointTextLayout.setOnClickListener(onFabClickListener);
lineFab = (FloatingActionButton) mainView.findViewById(R.id.line_fab);
lineFab.setOnClickListener(onFabClickListener);
lineTextLayout = mainView.findViewById(R.id.line_text_layout);
lineTextLayout.setOnClickListener(onFabClickListener);
TextView tv = new TextView(getActivity());
tv.setText(R.string.none_selected_gpx);
tv.setTextSize(24);
listView.setEmptyView(tv);
setContent(listView);
setListView(listView);
expandAllGroups();
return mainView;
}
use of android.widget.ExpandableListView in project Osmand by osmandapp.
the class SearchDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
if (savedInstanceState != null) {
searchText = savedInstanceState.getString(SEARCH_TEXT_DLG_KEY);
}
if (searchText == null) {
searchText = getArguments().getString(SEARCH_TEXT_DLG_KEY);
}
if (searchText == null)
searchText = "";
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity(), false);
LinearLayout ll = (LinearLayout) view;
ExpandableListView expandablelistView = (ExpandableListView) view.findViewById(android.R.id.list);
ll.removeView(expandablelistView);
listView = new ListView(getActivity());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
layoutParams.weight = 1;
layoutParams.setMargins(0, 0, 0, 0);
listView.setLayoutParams(layoutParams);
ll.addView(listView);
listView.setOnItemClickListener(this);
listAdapter = new SearchListAdapter(getDownloadActivity());
listView.setOnItemClickListener(this);
listView.setAdapter(listAdapter);
TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.toolbar_theme, typedValue, true);
searchView = inflater.inflate(R.layout.search_text_layout, toolbar, false);
toolbar.addView(searchView);
searchEditText = (EditText) view.findViewById(R.id.searchEditText);
searchEditText.setHint(R.string.search_map_hint);
searchEditText.setTextColor(Color.WHITE);
boolean isLight = getMyApplication().getSettings().isLightContent();
searchEditText.setHintTextColor(isLight ? getMyApplication().getResources().getColor(R.color.inactive_item_orange) : getMyApplication().getResources().getColor(R.color.searchbar_tab_inactive_dark));
progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar);
clearButton = (ImageButton) view.findViewById(R.id.clearButton);
clearButton.setVisibility(View.GONE);
searchEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateSearchText(s.toString());
}
});
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (searchEditText.getText().length() == 0) {
dismiss();
} else {
searchEditText.setText("");
}
}
});
searchEditText.requestFocus();
return view;
}
use of android.widget.ExpandableListView in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
if (savedInstanceState != null) {
groupId = savedInstanceState.getString(REGION_ID_DLG_KEY);
}
if (groupId == null && getArguments() != null) {
groupId = getArguments().getString(REGION_ID_DLG_KEY);
}
if (groupId == null) {
groupId = "";
}
activity = (DownloadActivity) getActivity();
activity.getAccessibilityAssistant().registerPage(view, DownloadActivity.DOWNLOAD_TAB_NUMBER);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
if (!openAsDialog()) {
toolbar.setVisibility(View.GONE);
}
setHasOptionsMenu(true);
if (openAsDialog()) {
banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity(), false);
} else {
banner = null;
view.findViewById(R.id.freeVersionBanner).setVisibility(View.GONE);
}
listView = (ExpandableListView) view.findViewById(android.R.id.list);
addSubscribeEmailRow();
addSearchRow();
addRestorePurchasesRow();
listView.setOnChildClickListener(this);
listAdapter = new DownloadResourceGroupAdapter(activity);
listView.setAdapter(listAdapter);
return view;
}
use of android.widget.ExpandableListView in project Osmand by osmandapp.
the class FavoritesTreeFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.favorites_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
favouritesAdapter.synchronizeGroups();
if (!favouritesAdapter.isEmpty()) {
boolean light = getMyApplication().getSettings().isLightContent();
View searchView = inflater.inflate(R.layout.search_fav_list_item, null);
searchView.setBackgroundResource(light ? R.color.bg_color_light : R.color.bg_color_dark);
TextView title = (TextView) searchView.findViewById(R.id.title);
title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
title.setHint(R.string.shared_string_search);
searchView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FavoritesSearchFragment.showInstance(getActivity(), "");
}
});
listView.addHeaderView(searchView);
listView.addHeaderView(inflater.inflate(R.layout.list_item_divider, null, false));
footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
listView.addFooterView(footerView);
}
View emptyView = view.findViewById(android.R.id.empty);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_favorites_day : R.drawable.ic_empty_state_favorites_night);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
importFavourites();
}
});
listView.setEmptyView(emptyView);
listView.setAdapter(favouritesAdapter);
setListView(listView);
setHasOptionsMenu(true);
listView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
String groupName = favouritesAdapter.getGroup(groupPosition).name;
getGroupExpandedPreference(groupName).set(false);
}
});
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
String groupName = favouritesAdapter.getGroup(groupPosition).name;
getGroupExpandedPreference(groupName).set(true);
}
});
String groupNameToShow = ((FavoritesActivity) getActivity()).getGroupNameToShow();
if (groupNameToShow != null) {
int groupPos = favouritesAdapter.getGroupPosition(groupNameToShow);
if (groupPos != -1) {
listView.expandGroup(groupPos);
int selection = listView.getHeaderViewsCount();
for (int i = 0; i < groupPos; i++) {
// because of group header
selection++;
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).name).get()) {
selection += favouritesAdapter.getChildrenCount(i);
}
}
listView.setSelection(selection);
}
}
return view;
}
Aggregations