List of usage examples for android.widget ListView addHeaderView
public void addHeaderView(View v)
From source file:nz.ac.otago.psyanlab.common.designer.source.SourceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_designer_source_detail, container, false); ListView list = (ListView) view.findViewById(R.id.columns); list.addHeaderView(inflater.inflate(R.layout.header_source_detail, list, false)); list.addFooterView(inflater.inflate(R.layout.footer_source_detail, list, false)); return view;/*w ww.j av a2 s.c om*/ }
From source file:com.androidquery.simplefeed.fragments.CommentFragment.java
private void initView() { comments = new CommentAdapter(); aq.id(R.id.list);/*from ww w . j ava 2s . c o m*/ ListView lv = aq.getListView(); header = aq.inflate(null, R.layout.fragment_comment_header, null); lv.addHeaderView(header); aq.adapter(comments).scrolledBottom(this, "scrolledBottom").itemClicked(this, "itemClicked"); aq.id(R.id.button_send).clicked(this, "send"); aq.id(R.id.content_tb).clicked(this, "contentClicked"); aq.id(R.id.content_name).clicked(this, "contentClicked"); aq.id(R.id.edit_comment).clicked(this, "editClicked"); }
From source file:com.todoroo.astrid.actfm.TagUpdatesFragment.java
private void addHeaderToListView(ListView listView) { if (AndroidUtilities.isTabletSized(getActivity()) && tagData != null) { listHeader = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.tag_updates_header, listView, false);//from www . ja va 2s. co m populateListHeader(listHeader); listView.addHeaderView(listHeader); } }
From source file:com.concentricsky.android.khanacademy.app.VideoListActivity.java
@Override protected void onStart() { Log.d(LOG_TAG, "onStart"); super.onStart(); stopped = false;/*from w w w.j a v a 2 s .c om*/ mainMenuDelegate = new MainMenuDelegate(this); listView = (AbsListView) findViewById(android.R.id.list); listView.setOnItemClickListener(clickListener); if (listView instanceof ListView) { // It is important that this is inflated with listView passed as the parent, despite the attach false parameter. // Otherwise, the view ends up with incorrect LayoutParams and we see crazy, crazy behavior. headerView = getLayoutInflater().inflate(R.layout.header_video_list, listView, false); ListView lv = (ListView) listView; if (lv.getHeaderViewsCount() == 0) { lv.addHeaderView(headerView); } } else { // GridView, fixed header headerView = findViewById(R.id.header_video_list); } /** Responsive layout stuff * * Based on screen width, we will find either * narrow * a listview with a header view * items are a thumbnail to the left and a title on white space to the right. * header is a thumbnail with overlaid title across the bottom * * middle * a fixed header on top and a grid view below * header is thumb to left, title above scrolling description to right * items are thumbs with title overlaid across the bottom (3 across) * * wide * a fixed header to the left and a grid view on the right * header is thumb on top, title next, description at bottom * items are thumbs with title overlaid across the bottom (3 across) * * * So in this class, we * find view by id 'list' * if it's a ListView, inflate and attach header view * if not, then the header is fixed and already in the layout * either way, now we can find header views by id * adapter is the same either way * * * * **/ ActionBar ab = getActionBar(); displayOptionsAdapter = new ArrayAdapter<String>(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, displayOptions); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle(""); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ab.setListNavigationCallbacks(displayOptionsAdapter, navListener); ab.setSelectedNavigationItem(isShowingDownloadedVideosOnly ? 1 : 0); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(KADataService dataService) { VideoListActivity.this.dataService = dataService; if (topicId != null) { Dao<Topic, String> topicDao; try { topicDao = dataService.getHelper().getTopicDao(); topic = topicDao.queryForId(topicId); } catch (SQLException e) { e.printStackTrace(); } } else { Log.e(LOG_TAG, "Topic id not set for video list"); topic = dataService.getRootTopic(); topicId = topic.getId(); } thumbnailManager = dataService.getThumbnailManager(); api = dataService.getAPIAdapter(); api.registerUserUpdateListener(userUpdateListener); // This instead happens in ActionBar.OnNavigationListener#onNavigationItemSelected, which // fires after onResume. // setParentTopic(topic); } }); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED); filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE); filter.addAction(ACTION_TOAST); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter); thumbExecutor = Executors.newSingleThreadExecutor(); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.ExploreFragment.java
private void addMapHeaderView() { ListView listView = getListView(); final Context context = listView.getContext(); View mapHeaderContainerView = LayoutInflater.from(context).inflate(R.layout.list_item_track_map, listView, false);//from w w w . j a v a 2s . c o m View mapButton = mapHeaderContainerView.findViewById(R.id.map_button); mapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Launch map of conference venue EasyTracker.getTracker().sendEvent("Explore Tab", "Click", "Map", 0L); startActivity(new Intent(context, UIUtils.getMapActivityClass(getActivity()))); } }); listView.addHeaderView(mapHeaderContainerView); listView.setHeaderDividersEnabled(false); }
From source file:com.yeldi.yeldibazaar.AppDetails.java
@Override protected void onCreate(Bundle savedInstanceState) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) setTheme(R.style.AppThemeLight); super.onCreate(savedInstanceState); ActionBarCompat abCompat = ActionBarCompat.create(this); abCompat.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.appdetails); Intent i = getIntent();//from www. jav a 2s. co m appid = ""; Uri data = getIntent().getData(); if (data != null) { if (data.isHierarchical()) { if (data.getHost().equals("details")) { // market://details?id=app.id appid = data.getQueryParameter("id"); } else { // https://f-droid.org/app/app.id appid = data.getLastPathSegment(); } } else { // fdroid.app:app.id (old scheme) appid = data.getEncodedSchemeSpecificPart(); } Log.d("FDroid", "AppDetails launched from link, for '" + appid + "'"); } else if (!i.hasExtra("appid")) { Log.d("FDroid", "No application ID in AppDetails!?"); } else { appid = i.getStringExtra("appid"); } // Set up the list... headerView = new LinearLayout(this); ListView lv = (ListView) findViewById(android.R.id.list); lv.addHeaderView(headerView); ApkListAdapter la = new ApkListAdapter(this, null); setListAdapter(la); mPm = getPackageManager(); // Get the preferences we're going to use in this Activity... AppDetails old = (AppDetails) getLastNonConfigurationInstance(); if (old != null) { copyState(old); } else { if (!reset()) { finish(); return; } resetRequired = false; } startViews(); }
From source file:com.androidquery.simplefeed.fragments.FeedFragment.java
private void initView() { items = new FeedAdapter(); items.setLoadable(true);/*from www . j a v a2 s.co m*/ aq.id(R.id.list); if (act.isRoot()) { ListView lv = aq.getListView(); header = aq.inflate(null, R.layout.header_notification, null); lv.addHeaderView(header); } aq.adapter(items).scrolledBottom(this, "scrolledBottom").itemClicked(this, "itemClicked"); if (header != null) { aq.id(header).clicked(this, "notiClicked"); } selectedColor = getResources().getColor(R.color.selected); }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle arguments = getArguments();//from w w w . j ava2s . c o m sourcePosition = (Integer) arguments.get("position"); int colorFilterInt = AppSettings.getColorFilterInt(appContext); View view = inflater.inflate(R.layout.source_info_fragment, container, false); headerView = inflater.inflate(R.layout.source_info_header, null, false); settingsContainer = (RelativeLayout) headerView.findViewById(R.id.source_settings_container); sourceImage = (ImageView) headerView.findViewById(R.id.source_image); sourceTitle = (EditText) headerView.findViewById(R.id.source_title); sourcePrefix = (EditText) headerView.findViewById(R.id.source_data_prefix); sourceData = (EditText) headerView.findViewById(R.id.source_data); sourceSuffix = (EditText) headerView.findViewById(R.id.source_data_suffix); sourceNum = (EditText) headerView.findViewById(R.id.source_num); ViewGroup.LayoutParams params = sourceImage.getLayoutParams(); params.height = (int) ((container.getWidth() - 2f * getResources().getDimensionPixelSize(R.dimen.side_margin)) / 16f * 9); sourceImage.setLayoutParams(params); cancelButton = (Button) view.findViewById(R.id.cancel_button); saveButton = (Button) view.findViewById(R.id.save_button); sourcePrefix.setTextColor(colorFilterInt); sourceSuffix.setTextColor(colorFilterInt); cancelButton.setTextColor(colorFilterInt); saveButton.setTextColor(colorFilterInt); // Adjust alpha to get faded hint color from regular text color int hintColor = Color.argb(0x88, Color.red(colorFilterInt), Color.green(colorFilterInt), Color.blue(colorFilterInt)); sourceTitle.setHintTextColor(hintColor); sourceData.setHintTextColor(hintColor); sourceNum.setHintTextColor(hintColor); sourceData.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (type) { case AppSettings.FOLDER: selectSource(getPositionOfType(AppSettings.FOLDER)); break; case AppSettings.GOOGLE_ALBUM: selectSource(getPositionOfType(AppSettings.GOOGLE_ALBUM)); break; } Log.i(TAG, "Data launched folder fragment"); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveSource(); } }); sourceSpinnerText = (TextView) headerView.findViewById(R.id.source_spinner_text); sourceSpinner = (Spinner) headerView.findViewById(R.id.source_spinner); timePref = (CustomSwitchPreference) findPreference("source_time"); timePref.setChecked(arguments.getBoolean("use_time")); timePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (!(Boolean) newValue) { return true; } DialogFactory.TimeDialogListener startTimeListener = new DialogFactory.TimeDialogListener() { @Override public void onTimeSet(TimePicker view, int hour, int minute) { startHour = hour; startMinute = minute; DialogFactory.TimeDialogListener endTimeListener = new DialogFactory.TimeDialogListener() { @Override public void onTimeSet(TimePicker view, int hour, int minute) { endHour = hour; endMinute = minute; timePref.setSummary(String.format("Time active: %02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)); } }; DialogFactory.showTimeDialog(appContext, "End time?", endTimeListener, startHour, startMinute); } }; DialogFactory.showTimeDialog(appContext, "Start time?", startTimeListener, startHour, startMinute); return true; } }); if (savedInstanceState != null) { if (sourcePosition == -1) { sourceSpinner .setSelection(getPositionOfType(savedInstanceState.getString("type", AppSettings.WEBSITE))); } } if (sourcePosition == -1) { sourceImage.setVisibility(View.GONE); sourceSpinnerText.setVisibility(View.VISIBLE); sourceSpinner.setVisibility(View.VISIBLE); SourceSpinnerAdapter adapter = new SourceSpinnerAdapter(appContext, R.layout.spinner_row, Arrays.asList(getResources().getStringArray(R.array.source_menu))); sourceSpinner.setAdapter(adapter); sourceSpinner.setSelection(0); sourceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { selectSource(position); Log.i(TAG, "Spinner launched folder fragment"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); type = AppSettings.WEBSITE; hint = "URL"; prefix = ""; suffix = ""; startHour = 0; startMinute = 0; endHour = 0; endMinute = 0; } else { sourceImage.setVisibility(View.VISIBLE); sourceSpinnerText.setVisibility(View.GONE); sourceSpinner.setVisibility(View.GONE); type = arguments.getString("type"); folderData = arguments.getString("data"); String data = folderData; hint = AppSettings.getSourceDataHint(type); prefix = AppSettings.getSourceDataPrefix(type); suffix = ""; switch (type) { case AppSettings.GOOGLE_ALBUM: sourceTitle.setFocusable(false); sourceData.setFocusable(false); sourceNum.setFocusable(false); case AppSettings.FOLDER: data = Arrays.toString(folderData.split(AppSettings.DATA_SPLITTER)); break; case AppSettings.TUMBLR_BLOG: suffix = ".tumblr.com"; break; } sourceTitle.setText(arguments.getString("title")); sourceNum.setText("" + arguments.getInt("num")); sourceData.setText(data); if (imageDrawable != null) { sourceImage.setImageDrawable(imageDrawable); } boolean showPreview = arguments.getBoolean("preview"); if (showPreview) { sourceImage.setVisibility(View.VISIBLE); } ((CustomSwitchPreference) findPreference("source_show_preview")).setChecked(showPreview); String[] timeArray = arguments.getString("time").split(":|[ -]+"); try { startHour = Integer.parseInt(timeArray[0]); startMinute = Integer.parseInt(timeArray[1]); endHour = Integer.parseInt(timeArray[2]); endMinute = Integer.parseInt(timeArray[3]); timePref.setSummary(String.format("Time active: %02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)); } catch (NumberFormatException e) { e.printStackTrace(); startHour = 0; startMinute = 0; endHour = 0; endMinute = 0; } } setDataWrappers(); sourceUse = (Switch) headerView.findViewById(R.id.source_use_switch); sourceUse.setChecked(arguments.getBoolean("use")); if (AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME)) { view.setBackgroundColor(getResources().getColor(R.color.LIGHT_THEME_BACKGROUND)); } else { view.setBackgroundColor(getResources().getColor(R.color.DARK_THEME_BACKGROUND)); } ListView listView = (ListView) view.findViewById(android.R.id.list); listView.addHeaderView(headerView); if (savedInstanceState != null) { sourceTitle.setText(savedInstanceState.getString("title", "")); sourceData.setText(savedInstanceState.getString("data", "")); sourceNum.setText(savedInstanceState.getString("num", "")); } return view; }
From source file:com.microsoft.live.sample.hotmail.ContactsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_contacts); ListView lv = getListView(); lv.setTextFilterEnabled(true);//from ww w.j av a 2 s.com lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Contact contact = (Contact) parent.getItemAtPosition(position); ViewContactDialog dialog = new ViewContactDialog(ContactsActivity.this, contact); dialog.setOwnerActivity(ContactsActivity.this); dialog.show(); } }); LinearLayout layout = new LinearLayout(this); Button newCalendarButton = new Button(this); newCalendarButton.setText("New Contact"); newCalendarButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CreateContactDialog dialog = new CreateContactDialog(ContactsActivity.this); dialog.setOwnerActivity(ContactsActivity.this); dialog.show(); } }); layout.addView(newCalendarButton); lv.addHeaderView(layout); mAdapter = new ContactsListAdapter(this); setListAdapter(mAdapter); LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication(); mClient = app.getConnectClient(); }
From source file:org.deviceconnect.android.deviceplugin.health.fragment.HealthCareDeviceSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mDeviceAdapter = new DeviceAdapter(getActivity(), createDeviceContainers()); mRootView = inflater.inflate(R.layout.fragment_heart_rate_device_settings, null); final ListView listView = (ListView) mRootView.findViewById(R.id.device_list_view); mFooterView = inflater.inflate(R.layout.bluetooth_list_footer_view, null); // ???????/*w w w . j a v a 2 s. c o m*/ View headerView = inflater.inflate(R.layout.bluetooth_list_header_view, null); Button button = (Button) headerView.findViewById(R.id.button_scan); if (getManager().isScanning()) { button.setText(R.string.heart_rate_setting_button_stop); } button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onClickScanButton(); } }); listView.addHeaderView(headerView); listView.setAdapter(mDeviceAdapter); // Bluetooth?????ON/OFF? mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter != null) { mBluetoothSwitch = (Switch) mRootView.findViewById(R.id.switch_bluetooth); if (mBluetoothSwitch != null) { if (mBluetoothAdapter.isEnabled()) { mBluetoothSwitch.setChecked(true); mRootView.findViewById(R.id.text_bluetooth_settings).setVisibility(View.GONE); mRootView.findViewById(R.id.device_list_view).setVisibility(View.VISIBLE); } else { mBluetoothSwitch.setChecked(false); mRootView.findViewById(R.id.text_bluetooth_settings).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.device_list_view).setVisibility(View.GONE); } } mBluetoothSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { mBluetoothAdapter.enable(); mBluetoothSwitch.setEnabled(false); } else { mBluetoothAdapter.disable(); mBluetoothSwitch.setEnabled(false); } } }); getManager().setOnBluetoothStateChangedListener(mBLEListener); } return mRootView; }