List of usage examples for android.widget ListView addHeaderView
public void addHeaderView(View v, Object data, boolean isSelectable)
From source file:com.digitalbuana.smiles.ui.ContactAdd.java
@Override protected void onInflate(Bundle savedInstanceState) { setContentView(R.layout.contact_add); ListView listView = getListView(); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.contact_add_header, listView, false); listView.addHeaderView(view, null, false); // accountView = (Spinner) view.findViewById(R.id.contact_account); // accountView.setAdapter(new AccountChooseAdapter(this)); // accountView.setOnItemSelectedListener(this); userView = (EditText) view.findViewById(R.id.contact_user); nameView = (EditText) view.findViewById(R.id.contact_name); ((Button) view.findViewById(R.id.ok)).setOnClickListener(this); String name;/*from w w w . j a v a2s . co m*/ Intent intent = getIntent(); if (savedInstanceState != null) { account = savedInstanceState.getString(SAVED_ACCOUNT); user = savedInstanceState.getString(SAVED_USER); name = savedInstanceState.getString(SAVED_NAME); } else { account = getAccount(intent); user = getUser(intent); if (account == null || user == null) name = null; else { name = RosterManager.getInstance().getName(account, user); if (user.equals(name)) name = null; } } if (account == null) { Collection<String> accounts = AccountManager.getInstance().getAccounts(); if (accounts.size() == 1) account = accounts.iterator().next(); } // if (account != null) { // for (int position = 0; position < accountView.getCount(); position++) // if (account.equals(accountView.getItemAtPosition(position))) { // accountView.setSelection(position); // break; // } // } if (user != null) userView.setText(StringUtils.replaceStringEquals(user)); if (name != null) nameView.setText(name); if (ACTION_SUBSCRIPTION_REQUEST.equals(intent.getAction())) { subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user); if (subscriptionRequest == null) { Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); finish(); return; } } else { subscriptionRequest = null; } }
From source file:org.deviceconnect.android.deviceplugin.hue.activity.fragment.HueFragment01.java
@SuppressLint("InflateParams") @Override/*w w w .j a va 2 s.c o m*/ public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.hue_fragment_01, container, false); if (rootView != null) { mSearchButton = (Button) rootView.findViewById(R.id.btnRefresh); mSearchButton.setOnClickListener(this); mProgressView = rootView.findViewById(R.id.progress_zone); mProgressView.setVisibility(View.VISIBLE); mAdapter = new CustomAdapter(getActivity().getBaseContext(), HueManager.INSTANCE.getAccessPoint()); ListView listView = (ListView) rootView.findViewById(R.id.bridge_list2); listView.setOnItemClickListener(this); View headerView = inflater.inflate(R.layout.hue_fragment_01_header, null, false); listView.addHeaderView(headerView, null, false); listView.setAdapter(mAdapter); } return rootView; }
From source file:com.happysanta.vkspy.Fragments.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity();//from ww w . j a v a 2 s. c om if (savedInstanceState != null && UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); } View rootView = inflater.inflate(R.layout.fragment_main, null); View happySanta = inflater.inflate(R.layout.main_santa, null); TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText); happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description))); TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink); happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>")); happySantaLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta")); startActivity(browserIntent); } }); happySanta.setOnClickListener(new View.OnClickListener() { int i = 1; @Override public void onClick(View v) { if (i < 10) i++; else { i = 0; File F = Logs.getFile(); Uri U = Uri.fromFile(F); Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_STREAM, U); startActivity(Intent.createChooser(i, "What should we do with logs?")); } } }); SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll", Context.MODE_MULTI_PROCESS); boolean longpollStatus = longpollPreferences.getBoolean("status", true); /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline); BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile); tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT); santaGroundView.setBackgroundDrawable(tiledBitmapDrawable); BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource( getResources(), R.drawable.underline2)); bitmap.setTileModeX(Shader.TileMode.REPEAT); */ LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); // deprecated for (int i = 0; width % (341 * i + 1) < width; i++) { layout.addView(new ImageView(context) { { setImageResource(R.drawable.underline2); setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4))); setScaleType(ScaleType.CENTER_CROP); } }); } ListView preferencesView = (ListView) rootView.findViewById(R.id.preference); preferencesView.addHeaderView(happySanta, null, false); ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>(); /* preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) { @Override public void onClick() { if(UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog selector; View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null); SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS); boolean updateOnly = durovPreferences.getBoolean("loaded", false); if(updateOnly) ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated); if(Memory.users.getById(1)!=null && !updateOnly) { builder.setTitle(R.string.durov_joke_title); ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message); ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE); builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent("? ? "); } }); BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1"); }else{ builder.setTitle(R.string.durov_start_title); ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo)); builder. setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent(" "); ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(), context.getString(R.string.durov_function_activating_title), context.getString(R.string.durov_function_activating_message), true, false); UberFunktion.initialize(uberfunctionDialog); } }); builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("https://vk.com/id1") ); startActivity(browserIntent); }catch(Exception exp){ AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity()); if (exp instanceof ActivityNotFoundException) { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.no_browser); } else { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.unknown_error); } errorShower.show(); } BugSenseHandler.sendEvent("? ? "); } }); } builder.setView(durov); selector = builder.create(); selector.show(); } }); */ preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) { @Override public void onToggle(Boolean isChecked) { longpollToggle(isChecked); } }); preferences.add(new PreferenceItem(getAdvancedSettings()) { @Override public void onClick() { startActivity(new Intent(context, SettingsActivity.class)); } }); preferences.add(new PreferenceItem(getAbout()) { @Override public void onClick() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog aboutDialog; builder.setTitle(R.string.app_about).setCancelable(true) .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null); TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description); aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description))); aboutDescription.setMovementMethod(LinkMovementMethod.getInstance()); aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(context, InfoActivity.class); startActivity(browserIntent); } }); builder.setView(aboutView); aboutDialog = builder.create(); aboutDialog.setCanceledOnTouchOutside(true); aboutDialog.show(); } }); preferencesView.setAdapter(new PreferenceAdapter(context, preferences)); return rootView; }
From source file:org.videolan.vlc.gui.SearchFragment.java
private void showListHeader(String text) { ListView lv = getListView(); // Create a new header if it doesn't already exist if (mListHeader == null) { LayoutInflater infalter = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mListHeader = (LinearLayout) infalter.inflate(R.layout.list_header, lv, false); lv.addHeaderView(mListHeader, null, false); }/*ww w .j av a 2s. co m*/ // Set header text TextView headerText = (TextView) mListHeader.findViewById(R.id.text); headerText.setText(text); }
From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); deleteRegistrarAck();// w ww. j ava2s.com setHasOptionsMenu(true); onVisibilityChanged_custom(true); ListView lv = getListView(); if (getListAdapter() == null && mHeaderView != null) { lv.addHeaderView(mHeaderView, null, true); } lv.setOnCreateContextMenuListener(this); }
From source file:it.gulch.linuxday.android.fragments.PersonInfoListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText(getString(R.string.no_data)); int contentMargin = getResources().getDimensionPixelSize(R.dimen.content_margin); ListView listView = getListView(); listView.setPadding(contentMargin, contentMargin, contentMargin, contentMargin); listView.setClipToPadding(false);/*from www.ja va2s. co m*/ listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.header_person_info, null); ((TextView) headerView.findViewById(R.id.title)) .setText(person.getCompleteName(Person.CompleteNameEnum.NAME_FIRST)); listView.addHeaderView(headerView, null, false); setListAdapter(adapter); setListShown(false); setupLoaderCallbacks(); }
From source file:it.gulch.linuxday.android.activities.MainActivity.java
private void setupMainMenu() { mainMenu = findViewById(R.id.main_menu); ListView menuListView = (ListView) findViewById(R.id.main_menu_list); LayoutInflater inflater = LayoutInflater.from(this); View menuHeaderView = inflater.inflate(R.layout.header_main_menu, null); menuListView.addHeaderView(menuHeaderView, null, false); LocalBroadcastManager.getInstance(this).registerReceiver(scheduleRefreshedReceiver, new IntentFilter(ActionConstants.ACTION_SCHEDULE_REFRESHED)); menuAdapter = new MainMenuAdapter(inflater); menuListView.setAdapter(menuAdapter); menuListView.setOnItemClickListener(this); // Last update date, below the menu lastUpdateTextView = (TextView) findViewById(R.id.last_update); updateLastUpdateTime();//from w w w. j a va 2 s . c o m // Ensure the current section is visible in the menu menuListView.setSelection(currentSection.ordinal()); }
From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java
@Override void setupViews(ViewGroup view) { if (showSearchBox) { ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view); View searchHeaderView = getActivity().getLayoutInflater().inflate(R.layout.picker_search_box, listView, false);// w w w . j a va 2s.c o m listView.addHeaderView(searchHeaderView, null, false); searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text); searchBox.addTextChangedListener(new SearchTextWatcher()); if (!TextUtils.isEmpty(searchText)) { searchBox.setText(searchText); } } }
From source file:heartware.com.FB_picker.PlacePickerFragment.java
@Override void setupViews(ViewGroup view) { if (showSearchBox) { ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view); View searchHeaderView = getActivity().getLayoutInflater().inflate(R.layout.fb_picker_search_box, listView, false);/* w ww.j av a 2 s . c o m*/ listView.addHeaderView(searchHeaderView, null, false); searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text); searchBox.addTextChangedListener(new SearchTextWatcher()); if (!TextUtils.isEmpty(searchText)) { searchBox.setText(searchText); } } }
From source file:com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtilsTest.java
public void testListWithHeaderOnly() throws Throwable { setContentView(R.layout.list_with_single_item); final Context context = getActivity(); final ListView list = (ListView) getViewForId(R.id.list); // Add a single list header. final LayoutInflater inflater = LayoutInflater.from(context); final View headerView = inflater.inflate(R.layout.list_header_row, list, false); // Add an adapter with no items. final ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1); runTestOnUiThread(new Runnable() { @Override/*from www . j av a 2 s . c o m*/ public void run() { list.addHeaderView(headerView, context.getString(R.string.list_header), false); list.setAdapter(adapter); } }); waitForAccessibilityIdleSync(); assertShouldFocusNode("Non-selectable header is focusable", R.id.header_item, true); assertShouldFocusNode("List is not focusable", R.id.list, false); assertFocusFromHover("Non-selectable header receives focus", R.id.header_item, R.id.header_item); assertFocusFromHover("List does not receive focus", R.id.list, -1); }